Ignore:
Timestamp:
05/01/10 12:37:16 (12 years ago)
Author:
epitzer
Message:

throw Exception if class is marked [Storable] but cannot be serialized with the StorableSerializer (#548)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/Serializer.cs

    r3016 r3577  
    223223            compositeSerializer.CreateMetaInfo(value),
    224224            emitTypeInfo);
    225         throw CreatePersistenceException(type);
     225        throw CreatePersistenceException(type, "Could not determine how to serialize a value.");     
    226226      } catch (Exception x) {
    227227        if (isTestRun) {
    228228          exceptions.Add(x);
    229229          return new List<ISerializationToken>().GetEnumerator();
     230        } else if (x is PersistenceException) {
     231          throw;
    230232        } else {
    231           throw;
     233          throw CreatePersistenceException(type, "Uncaught exception during serialization: " + x.Message);
    232234        }
    233235      } finally {
     
    236238    }
    237239
    238     private PersistenceException CreatePersistenceException(Type type) {
     240    private PersistenceException CreatePersistenceException(Type type, string message) {
    239241      StringBuilder sb = new StringBuilder();
    240       sb.Append("Could not determine how to serialize a value of type \"")
     242      sb.Append(message)
     243        .Append("Type was \"")
    241244        .Append(type.VersionInvariantName())
    242245        .AppendLine("\"")
     
    248251          .Append(" ---- (")
    249252          .Append(ps.GetType().VersionInvariantName())
    250           .AppendLine(")");         
     253          .AppendLine(")");
    251254      sb.AppendLine("Rejected by all composite serializers:");
    252255      foreach (var cs in configuration.CompositeSerializers)
Note: See TracChangeset for help on using the changeset viewer.