Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Persistence Test/HeuristicLab.Persistence/3.3/Core/PersistenceException.cs @ 2733

Last change on this file since 2733 was 2106, checked in by epitzer, 15 years ago

Collect all exceptions during serialization and continue as far as possible. Throw a collected exception in th end. (#678)

File size: 1.1 KB
Line 
1using System.Collections.Generic;
2using System;
3using HeuristicLab.Persistence.Interfaces;
4using HeuristicLab.Persistence.Core.Tokens;
5using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
6using System.Text;
7
8namespace HeuristicLab.Persistence.Core {
9
10  [Serializable] 
11  public class PersistenceException : Exception {
12    public PersistenceException() : base() { }
13    public PersistenceException(string message) : base(message) { }
14    public PersistenceException(string message, Exception innerException) :  base(message, innerException) { }
15    public PersistenceException(string message, IEnumerable<Exception> innerExceptions)
16      : base(message) {
17      int i = 0;
18      foreach (var x in innerExceptions) {
19        i += 1;
20        this.Data.Add("Inner Exception " + i, x);
21      }
22    }
23    public override string ToString() {
24      var sb = new StringBuilder()
25        .Append(base.ToString())
26        .Append('\n');
27      foreach (Exception x in Data.Values) {
28        sb.Append(x.ToString()).Append('\n');
29      }
30      return sb.ToString();
31    }
32  }
33 
34}
Note: See TracBrowser for help on using the repository browser.