Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Persistence/3.3/Core/PersistenceException.cs @ 11401

Last change on this file since 11401 was 11170, checked in by ascheibe, 10 years ago

#2115 updated copyright year in stable branch

File size: 3.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2014 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;
23using System.Collections.Generic;
24using System.Runtime.Serialization;
25using System.Text;
26
27namespace HeuristicLab.Persistence.Core {
28
29  /// <summary>
30  /// Exception thrown by components inside the persistence framework.
31  /// </summary>
32  [Serializable]
33  public class PersistenceException : Exception {
34
35    /// <summary>
36    /// Initializes a new instance of the <see cref="PersistenceException"/> class.
37    /// </summary>
38    public PersistenceException() : base() { }
39
40    /// <summary>
41    /// Initializes a new instance of the <see cref="PersistenceException"/> class.
42    /// </summary>
43    /// <param name="message">The message.</param>
44    public PersistenceException(string message) : base(message) { }
45
46    /// <summary>
47    /// Initializes a new instance of the <see cref="PersistenceException"/> class.
48    /// </summary>
49    /// <param name="message">The message.</param>
50    /// <param name="innerException">The inner exception.</param>
51    public PersistenceException(string message, Exception innerException) :
52      base(message, innerException) { }
53
54    /// <summary>
55    /// Initializes a new instance of the <see cref="PersistenceException"/> class.
56    /// </summary>
57    /// <param name="message">The message.</param>
58    /// <param name="innerExceptions">The inner exceptions.</param>
59    public PersistenceException(string message, IEnumerable<Exception> innerExceptions)
60      : base(message) {
61      int i = 0;
62      foreach (var x in innerExceptions) {
63        i += 1;
64        this.Data.Add("Inner Exception " + i, x);
65      }
66    }
67
68    protected PersistenceException(SerializationInfo info, StreamingContext context) : base(info, context) { }
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.