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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Text;
|
---|
25 |
|
---|
26 | namespace HeuristicLab.Persistence.Core {
|
---|
27 |
|
---|
28 | /// <summary>
|
---|
29 | /// Exception thrown by components inside the persistence framework.
|
---|
30 | /// </summary>
|
---|
31 | [Serializable]
|
---|
32 | public class PersistenceException : Exception {
|
---|
33 |
|
---|
34 | /// <summary>
|
---|
35 | /// Initializes a new instance of the <see cref="PersistenceException"/> class.
|
---|
36 | /// </summary>
|
---|
37 | public PersistenceException() : base() { }
|
---|
38 |
|
---|
39 | /// <summary>
|
---|
40 | /// Initializes a new instance of the <see cref="PersistenceException"/> class.
|
---|
41 | /// </summary>
|
---|
42 | /// <param name="message">The message.</param>
|
---|
43 | public PersistenceException(string message) : base(message) { }
|
---|
44 |
|
---|
45 | /// <summary>
|
---|
46 | /// Initializes a new instance of the <see cref="PersistenceException"/> class.
|
---|
47 | /// </summary>
|
---|
48 | /// <param name="message">The message.</param>
|
---|
49 | /// <param name="innerException">The inner exception.</param>
|
---|
50 | public PersistenceException(string message, Exception innerException) :
|
---|
51 | base(message, innerException) { }
|
---|
52 |
|
---|
53 | /// <summary>
|
---|
54 | /// Initializes a new instance of the <see cref="PersistenceException"/> class.
|
---|
55 | /// </summary>
|
---|
56 | /// <param name="message">The message.</param>
|
---|
57 | /// <param name="innerExceptions">The inner exceptions.</param>
|
---|
58 | public PersistenceException(string message, IEnumerable<Exception> innerExceptions)
|
---|
59 | : base(message) {
|
---|
60 | int i = 0;
|
---|
61 | foreach (var x in innerExceptions) {
|
---|
62 | i += 1;
|
---|
63 | this.Data.Add("Inner Exception " + i, x);
|
---|
64 | }
|
---|
65 | }
|
---|
66 |
|
---|
67 | /// <summary>
|
---|
68 | /// Returns a <see cref="System.String"/> that represents this instance.
|
---|
69 | /// </summary>
|
---|
70 | /// <returns>
|
---|
71 | /// A <see cref="System.String"/> that represents this instance.
|
---|
72 | /// </returns>
|
---|
73 | /// <PermissionSet>
|
---|
74 | /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" PathDiscovery="*AllFiles*"/>
|
---|
75 | /// </PermissionSet>
|
---|
76 | public override string ToString() {
|
---|
77 | var sb = new StringBuilder()
|
---|
78 | .Append(base.ToString())
|
---|
79 | .Append('\n');
|
---|
80 | foreach (Exception x in Data.Values) {
|
---|
81 | sb.Append(x.ToString()).Append('\n');
|
---|
82 | }
|
---|
83 | return sb.ToString();
|
---|
84 | }
|
---|
85 | }
|
---|
86 |
|
---|
87 | } |
---|