Changeset 16907


Ignore:
Timestamp:
05/07/19 14:48:48 (3 weeks ago)
Author:
gkronber
Message:

#2520 Show more info in the exception dialog when persistence fails

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Core/3.3/PersistenceContentManager.cs

    r16579 r16907  
    2424using HeuristicLab.Persistence.Default.Xml;
    2525using HEAL.Attic;
    26 using System;
    2726
    2827namespace HeuristicLab.Core {
     
    3231    protected override IStorableContent LoadContent(string filename) {
    3332      // first try to load using the new persistence format
    34       try {
    35         var ser = new ProtoBufSerializer();
    36         return (IStorableContent)ser.Deserialize(filename);
    37       } catch (Exception) {
    38         // try old format if new format fails
    39         return XmlParser.Deserialize<IStorableContent>(filename);
     33      var ser = new ProtoBufSerializer();
     34      var o = (IStorableContent)ser.Deserialize(filename, out SerializationInfo info);
     35      if (info.SerializedTypes != null) {
     36        return o;
    4037      }
     38      // try old format if new format fails
     39      return XmlParser.Deserialize<IStorableContent>(filename);
    4140    }
    4241
    4342    protected override void SaveContent(IStorableContent content, string filename, bool compressed, CancellationToken cancellationToken) {
    4443      var ser = new ProtoBufSerializer();
    45       ser.Serialize(content, filename, cancellationToken); 
     44      ser.Serialize(content, filename, cancellationToken);
    4645    }
    4746  }
Note: See TracChangeset for help on using the changeset viewer.