Free cookie consent management tool by TermsFeed Policy Generator

source: tags/3.3.0/HeuristicLab.Persistence/3.3/Core/PersistenceException.cs @ 13240

Last change on this file since 13240 was 3743, checked in by gkronber, 14 years ago

Fixed GPL license headers #893

File size: 3.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System.Collections.Generic;
23using System;
24using HeuristicLab.Persistence.Interfaces;
25using HeuristicLab.Persistence.Core.Tokens;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27using System.Text;
28
29namespace HeuristicLab.Persistence.Core {
30
31  /// <summary>
32  /// Exception thrown by components inside the persistence framework.
33  /// </summary>
34  [Serializable] 
35  public class PersistenceException : Exception {
36
37    /// <summary>
38    /// Initializes a new instance of the <see cref="PersistenceException"/> class.
39    /// </summary>
40    public PersistenceException() : base() { }
41
42    /// <summary>
43    /// Initializes a new instance of the <see cref="PersistenceException"/> class.
44    /// </summary>
45    /// <param name="message">The message.</param>
46    public PersistenceException(string message) : base(message) { }
47
48    /// <summary>
49    /// Initializes a new instance of the <see cref="PersistenceException"/> class.
50    /// </summary>
51    /// <param name="message">The message.</param>
52    /// <param name="innerException">The inner exception.</param>
53    public PersistenceException(string message, Exception innerException) :
54      base(message, innerException) { }
55
56    /// <summary>
57    /// Initializes a new instance of the <see cref="PersistenceException"/> class.
58    /// </summary>
59    /// <param name="message">The message.</param>
60    /// <param name="innerExceptions">The inner exceptions.</param>
61    public PersistenceException(string message, IEnumerable<Exception> innerExceptions)
62      : base(message) {
63      int i = 0;
64      foreach (var x in innerExceptions) {
65        i += 1;
66        this.Data.Add("Inner Exception " + i, x);
67      }
68    }
69
70    /// <summary>
71    /// Returns a <see cref="System.String"/> that represents this instance.
72    /// </summary>
73    /// <returns>
74    /// A <see cref="System.String"/> that represents this instance.
75    /// </returns>
76    /// <PermissionSet>
77    ///   <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" PathDiscovery="*AllFiles*"/>
78    /// </PermissionSet>
79    public override string ToString() {
80      var sb = new StringBuilder()
81        .Append(base.ToString())
82        .Append('\n');
83      foreach (Exception x in Data.Values) {
84        sb.Append(x.ToString()).Append('\n');
85      }
86      return sb.ToString();
87    }
88  }
89 
90}
Note: See TracBrowser for help on using the repository browser.