Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/23/09 14:22:29 (15 years ago)
Author:
epitzer
Message:

Added PersistenceException used consistently for all error conditions in the persistence framework (#548)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/DictionaryDecomposer.cs

    r1623 r1625  
    3939      IDictionary dict = (IDictionary)instance;
    4040      IEnumerator<Tag> iter = o.GetEnumerator();
    41       while (iter.MoveNext()) {
    42         Tag key = iter.Current;
    43         iter.MoveNext();
    44         Tag value = iter.Current;
    45         dict.Add(key.Value, value.Value);
    46       }
     41      try {
     42        while (iter.MoveNext()) {
     43          Tag key = iter.Current;
     44          iter.MoveNext();
     45          Tag value = iter.Current;
     46          dict.Add(key.Value, value.Value);
     47        }
     48      } catch (InvalidOperationException e) {
     49        throw new PersistenceException("Dictionaries must contain an even number of elements (key+value).", e);
     50      } catch (NotSupportedException e) {
     51        throw new PersistenceException("The serialized dictionary type was read-only or had a fixed size and cannot be deserialized.", e);
     52      } catch (ArgumentNullException e) {
     53        throw new PersistenceException("Dictionary key was null.", e);
     54      } catch (ArgumentException e) {
     55        throw new PersistenceException("Duplicate dictionary key.", e);
     56      }     
    4757    }
    4858  }
Note: See TracChangeset for help on using the changeset viewer.