Class ExceptionFormatter
Implements base functions for exception formatter.
Namespace: Sartorius.SAF.ExceptionHandling
Assembly: Sartorius.SAF.dll
Syntax
public abstract class ExceptionFormatter
Properties
View SourceAdditionalInfo
Gets additional information related to the Exception but not stored in the exception (eg: the time in which the Exception was thrown).
Declaration
public NameValueCollection AdditionalInfo { get; }
Property Value
Type | Description |
---|---|
System.Collections.Specialized.NameValueCollection | Additional information related to the Exception but not stored in the exception (for example, the time when the Exception was thrown). |
Exception
Gets the exception object.
Declaration
protected Exception Exception { get; }
Property Value
Type | Description |
---|---|
System.Exception |
Methods
View SourceFormat(Exception)
Formats the Exception into the underlying stream.
Declaration
public virtual string Format(Exception ex)
Parameters
Type | Name | Description |
---|---|---|
System.Exception | ex |
Returns
Type | Description |
---|---|
System.String |
WriteAdditionalInfo(NameValueCollection)
When overridden by a class, writes additional properties if available.
Declaration
protected abstract void WriteAdditionalInfo(NameValueCollection additionalInformation)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Specialized.NameValueCollection | additionalInformation | Additional information to be included with the exception report |
WriteDateTime(DateTime)
When overridden by a class, writes the current time.
Declaration
protected abstract void WriteDateTime(DateTime utcNow)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | utcNow | The current time. |
WriteDescription()
When overridden by a class, writes a description of the caught exception.
Declaration
protected abstract void WriteDescription()
WriteException(Exception, Exception)
Formats the exception and all nested inner exceptions.
Declaration
protected virtual void WriteException(Exception exceptionToFormat, Exception outerException)
Parameters
Type | Name | Description |
---|---|---|
System.Exception | exceptionToFormat | The exception to format. |
System.Exception | outerException | The outer exception. This value will be null when writing the outer-most exception. |
Remarks
This method calls itself recursively until it reaches an exception that does not have an inner exception.
This is a template method which calls the following methods in order
- WriteExceptionType(Type)
- WriteMessage(String)
- WriteSource(String)
- WriteHelpLink(String)
- WriteReflectionInfo(Exception)
- WriteStackTrace(String)
- If the specified exception has an inner exception then it makes a recursive call. WriteException(Exception, Exception)
WriteExceptionType(Type)
When overridden by a class, writes the System.Type of the current exception.
Declaration
protected abstract void WriteExceptionType(Type exceptionType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | exceptionType | The System.Type of the exception. |
WriteFieldInfo(FieldInfo, Object)
When overridden by a class, writes the value of a System.Reflection.FieldInfo object.
Declaration
protected abstract void WriteFieldInfo(FieldInfo fieldInfo, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.FieldInfo | fieldInfo | The reflected System.Reflection.FieldInfo object. |
System.Object | value | The value of the System.Reflection.FieldInfo object. |
WriteHelpLink(String)
When overridden by a class, writes the value of the System.Exception.HelpLink property.
Declaration
protected abstract void WriteHelpLink(string helpLink)
Parameters
Type | Name | Description |
---|---|---|
System.String | helpLink | The help link for the exception. |
WriteMessage(String)
When overridden by a class, writes the System.Exception.Message.
Declaration
protected abstract void WriteMessage(string message)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The message to write. |
WritePropertyInfo(PropertyInfo, Object)
When overridden by a class, writes the value of a System.Reflection.PropertyInfo object.
Declaration
protected abstract void WritePropertyInfo(PropertyInfo propertyInfo, object value)
Parameters
Type | Name | Description |
---|---|---|
System.Reflection.PropertyInfo | propertyInfo | The reflected System.Reflection.PropertyInfo object. |
System.Object | value | The value of the System.Reflection.PropertyInfo object. |
WriteReflectionInfo(Exception)
Formats an Exception using reflection to get the information.
Declaration
protected void WriteReflectionInfo(Exception exceptionToFormat)
Parameters
Type | Name | Description |
---|---|---|
System.Exception | exceptionToFormat | The Exception to be formatted. |
Remarks
This method reflects over the public, instance properties and public, instance fields of the specified exception and prints them to the formatter. Certain property names are ignored because they are handled explicitly in other places.
WriteSource(String)
When overridden by a class, writes the value of the System.Exception.Source property.
Declaration
protected abstract void WriteSource(string source)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The source of the exception. |
WriteStackTrace(String)
When overridden by a class, writes the value of the System.Exception.StackTrace property.
Declaration
protected abstract void WriteStackTrace(string stackTrace)
Parameters
Type | Name | Description |
---|---|---|
System.String | stackTrace | The stack trace of the exception. |