.NET Portable TypeCast  3.1.0.4
A, easy-to-use tested, generic, portable, runtime-extensible, arbitrary type converter library
ConverterCollectionException.cs
Go to the documentation of this file.
1 // <copyright file=mitlicense.md url=http://lsauer.mit-license.org/ >
2 // Lo Sauer, 2013-2016
3 // </copyright>
4 // <summary> A tested, generic, portable, runtime-extensible type converter library </summary
5 // <language> C# > 6.0 </language>
6 // <version> 3.1.0.2 </version>
7 // <author> Lorenz Lo Sauer; people credited in the sources </author>
8 // <project> https://github.com/lsauer/dotnet-portable-type-cast </project>
9 namespace Core.TypeCast
10 {
11  using System;
12 
13  using Core.Extensions;
14 
19  public class ConverterCollectionException : Exception, IException<ConverterCollectionCause>
20  {
30  public ConverterCollectionException(ConverterCollectionCause cause, string message = null)
31  : this(cause, null, message ?? cause.GetDescription())
32  {
33  }
34 
41  public ConverterCollectionException(ConverterCollectionCause cause, Exception innerException)
42  : this(cause, innerException, cause.GetDescription())
43  {
44  }
45 
53  public ConverterCollectionException(ConverterCollectionCause cause, Exception innerException, string message)
54  : base(message: message, innerException: innerException)
55  {
56  this.Cause = cause;
57  }
58 
65  public ConverterCollectionCause Cause { get; set; }
66 
71  public virtual string GetMessage()
72  {
73  return this.Cause.GetType().Name + " '" + this.Cause + "': " + this.Cause.GetDescription() + base.Message;
74  }
75 
80  public override string Message
81  {
82  get
83  {
84  return GetMessage();
85  }
86  }
87 
94  public override string ToString()
95  {
96  return this.GetMessage() + Environment.NewLine + base.ToString();
97  }
98  }
99 }
The common Exceptioninterface.
Definition: IException.cs:16
ConverterCollectionException(ConverterCollectionCause cause, string message=null)
Initializes a new instance of the ConverterCollectionException class. Requires a ConverterCollectionC...
override string ToString()
A string representation of the current exception.
virtual string GetMessage()
Override this method for custom formatting of the unformatted exception Exception.Message
ConverterCollectionCause
Contains the reasons for a ConverterCollectionException to be raised.
The Exception-type which is raised exclusively by the Converter<T> Library
ConverterCollectionException(ConverterCollectionCause cause, Exception innerException)
Initializes a new instance of the ConverterCollectionException class. Requires a ConverterCollectionC...
ConverterCollectionException(ConverterCollectionCause cause, Exception innerException, string message)
Initializes a new instance of the ConverterCollectionException class. Requires a ConverterCollectionC...