.NET Portable TypeCast  3.1.0.4
A, easy-to-use tested, generic, portable, runtime-extensible, arbitrary type converter library
ConverterException.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 ConverterException : Exception, IException, IException<ConverterCause>
20  {
30  public ConverterException(ConverterCause cause, string message = null)
31  : this(cause, null, message ?? cause.GetDescription())
32  {
33  }
34 
41  public ConverterException(ConverterCause cause, Exception innerException)
42  : this(cause, innerException, cause.GetDescription())
43  {
44  }
45 
53  public ConverterException(ConverterCause cause, Exception innerException, string message)
54  : base(message, innerException)
55  {
56  this.Cause = cause;
57  }
58 
65  public ConverterCause Cause { get; set; }
66 
71  public virtual string GetMessage()
72  {
73  return this.Cause.GetType().Name + " '" + this.Cause + "': " + this.Cause.GetDescription();
74  }
75 
79  public override string Message
80  {
81  get
82  {
83  return GetMessage();
84  }
85  }
86 
93  public override string ToString()
94  {
95  return this.GetMessage() + Environment.NewLine + base.ToString();
96  }
97  }
98 }
The common Exceptioninterface.
Definition: IException.cs:16
ConverterException(ConverterCause cause, Exception innerException)
Initializes a new instance of the ConverterException class. Requires a ConverterCause and innerExcept...
The Exception-type which is raised exclusively by the Converter<TIn,TOut> Library ...
ConverterException(ConverterCause cause, Exception innerException, string message)
Initializes a new instance of the ConverterException class. Requires a ConverterCause an innerExcepti...
ConverterException(ConverterCause cause, string message=null)
Initializes a new instance of the ConverterException class. Requires a ConverterCause and optional us...
virtual string GetMessage()
Override this method for custom formatting of the unformatted exception Exception.Message
override string ToString()
A string representation of the current exception.
ConverterCause
Contains the reasons for a ConverterException to be raised.