Class GorgonExceptionExtensions
Extension methods for the Exception type.
Inherited Members
Namespace: Gorgon.Core
Assembly: Gorgon.Core.dll
Syntax
public static class GorgonExceptionExtensions
Methods
| Edit this page View SourceCatch<T>(T, Action<T>, IGorgonLog)
Function to catch and handle an exception.
Declaration
public static void Catch<T>(this T ex, Action<T> handler, IGorgonLog log = null) where T : Exception
Parameters
Type | Name | Description |
---|---|---|
T | ex | Exception to pass to the handler. |
Action<T> | handler | A method that is called to handle the exception. |
IGorgonLog | log | [Optional] A logger that will capture the exception, or null to disable logging of this exception. |
Type Parameters
Name | Description |
---|---|
T | The type of exception. This value must be or inherit from the Exception type. |
Remarks
This is a convenience method used to catch an exception and then handle it with the supplied handler
method. The handler method must take a parameter
that has a type that is or derives from Exception.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
Repackage(Exception, GorgonResult)
Function to repackage an arbitrary exception as an Gorgon exception.
Declaration
public static GorgonException Repackage(this Exception ex, GorgonResult result)
Parameters
Type | Name | Description |
---|---|---|
Exception | ex | Exception to capture and rethrow. |
GorgonResult | result | Result code to use. |
Returns
Type | Description |
---|---|
GorgonException | A new Gorgon exception to throw. |
Remarks
The original exception will be the inner exception of the new GorgonException.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
Repackage(Exception, GorgonResult, string)
Function to repackage an arbitrary exception as a GorgonException.
Declaration
public static GorgonException Repackage(this Exception ex, GorgonResult result, string message)
Parameters
Type | Name | Description |
---|---|---|
Exception | ex | Exception to capture and rethrow. |
GorgonResult | result | Result code to use. |
string | message | Message to append to the result. |
Returns
Type | Description |
---|---|
GorgonException | A new Gorgon exception to throw. |
Remarks
The original exception will be the inner exception of the new GorgonException.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
Repackage(Exception, string)
Function to repackage an arbitrary exception as an Gorgon exception.
Declaration
public static GorgonException Repackage(this Exception ex, string message)
Parameters
Type | Name | Description |
---|---|---|
Exception | ex | Exception to capture and rethrow. |
string | message | New message to pass to the new exception. |
Returns
Type | Description |
---|---|
GorgonException | A new Gorgon exception to throw. |
Remarks
The original exception will be the inner exception of the new GorgonException.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |