Sphyrnidae Common Library  2.0.1
Shared Utilities/Library
Sphyrnidae.Common.Utilities.SafeTry Class Reference

Allows exceptions to be handled within a contained method More...

Static Public Member Functions

static async Task< T > OnException< T > (Func< Task< T >> method, Func< Exception, Task< T >> error)
 Wrapper which executes an asynchronous method safely, and allows the user to customize the exception handling asynchronously More...
 
static async Task< T > OnException< T > (Func< Task< T >> method, Func< Exception, T > error)
 Wrapper which executes an asynchronous method safely, and allows the user to customize the exception handling More...
 
static Task< T > OnException< T > (Func< T > method, Func< Exception, Task< T >> error)
 Wrapper which executes a method safely, and allows the user to customize the exception handling asynchronously More...
 
static T OnException< T > (Func< T > method, Func< Exception, T > error)
 Wrapper which executes a method safely, and allows the user to customize the exception handling More...
 
static async Task< bool > OnException (Func< Task > method, Func< Exception, Task< bool >> error)
 Wrapper which executes an asynchronous method safely, and allows the user to customize the exception handling asynchronously More...
 
static async Task< bool > OnException (Func< Task > method, Func< Exception, bool > error)
 Wrapper which executes an asynchronous method safely, and allows the user to customize the exception handling More...
 
static Task< bool > OnException (Action method, Func< Exception, Task< bool >> error)
 Wrapper which executes a method safely, and allows the user to customize the exception handling asynchronously More...
 
static bool OnException (Action method, Func< Exception, bool > error)
 Wrapper which executes a method safely, and allows the user to customize the exception handling More...
 
static async Task< T > IgnoreException< T > (Func< Task< T >> method, T defaultValue=default)
 Ensures that any exceptions thrown by the containing asynchronous method will be handled gracefully and code will resume past this block More...
 
static T IgnoreException< T > (Func< T > method, T defaultValue=default)
 Ensures that any exceptions thrown by the containing method will be handled gracefully and code will resume past this block More...
 
static async Task< bool > IgnoreException (Func< Task > method)
 Ensures that any exceptions thrown by the containing asynchronous method will be handled gracefully and code will resume past this block More...
 
static bool IgnoreException (Action method)
 Ensures that any exceptions thrown by the containing method will be handled gracefully and code will resume past this block More...
 
static async Task< T > EmailException< T > (IEmail email, IApplicationSettings app, Func< Task< T >> method, T defaultValue=default)
 Ensures that any exceptions thrown by the containing asynchronous method will be e-mailed and code will resume past this block More...
 
static Task< T > EmailException< T > (IEmail email, IApplicationSettings app, Func< T > method, T defaultValue=default)
 Ensures that any exceptions thrown by the containing method will be e-mailed and code will resume past this block More...
 
static async Task< bool > EmailException (IEmail email, IApplicationSettings app, Func< Task > method)
 Ensures that any exceptions thrown by the containing asynchronous method will be e-mailed and code will resume past this block More...
 
static Task< bool > EmailException (IEmail email, IApplicationSettings app, Action method)
 Ensures that any exceptions thrown by the containing method will be e-mailed and code will resume past this block More...
 
static async Task< T > LogException< T > (ILogger logger, Func< Task< T >> method, T defaultValue=default)
 Ensures that any exceptions thrown by the containing asynchronous method will be handled gracefully and code will resume past this block More...
 
static T LogException< T > (ILogger logger, Func< T > method, T defaultValue=default)
 Ensures that any exceptions thrown by the containing method will be handled gracefully and code will resume past this block More...
 
static async Task< bool > LogException (ILogger logger, Func< Task > method)
 Ensures that any exceptions thrown by the containing asynchronous method will be handled gracefully and code will resume past this block More...
 
static bool LogException (ILogger logger, Action method)
 Ensures that any exceptions thrown by the containing method will be handled gracefully and code will resume past this block More...
 

Detailed Description

Allows exceptions to be handled within a contained method

Member Function Documentation

◆ EmailException() [1/2]

static Task<bool> Sphyrnidae.Common.Utilities.SafeTry.EmailException ( IEmail  email,
IApplicationSettings  app,
Action  method 
)
static

Ensures that any exceptions thrown by the containing method will be e-mailed and code will resume past this block

Parameters
emailThe implementation of the IEmail interface
appThe implementation of the IApplicationSettings interface
methodThe method to execute which will have it's exceptions emailed
Returns
False if an exception was thrown, True if everything went off without exception

◆ EmailException() [2/2]

static async Task<bool> Sphyrnidae.Common.Utilities.SafeTry.EmailException ( IEmail  email,
IApplicationSettings  app,
Func< Task >  method 
)
static

Ensures that any exceptions thrown by the containing asynchronous method will be e-mailed and code will resume past this block

Parameters
emailThe implementation of the IEmail interface
appThe implementation of the IApplicationSettings interface
methodThe asynchronous method to execute which will have it's exceptions emailed
Returns
False if an exception was thrown, True if everything went off without exception

◆ EmailException< T >() [1/2]

static Task<T> Sphyrnidae.Common.Utilities.SafeTry.EmailException< T > ( IEmail  email,
IApplicationSettings  app,
Func< T >  method,
defaultValue = default 
)
static

Ensures that any exceptions thrown by the containing method will be e-mailed and code will resume past this block

Template Parameters
TThe return type of the function
Parameters
emailThe implementation of the IEmail interface
appThe implementation of the IApplicationSettings interface
methodThe method to execute which will have it's exceptions emailed
defaultValueIf an exception is thrown, this will be returned instead. Default = default(t). Eg. null for most classes
Returns
The return value from the calling method (or defaultValue)

◆ EmailException< T >() [2/2]

static async Task<T> Sphyrnidae.Common.Utilities.SafeTry.EmailException< T > ( IEmail  email,
IApplicationSettings  app,
Func< Task< T >>  method,
defaultValue = default 
)
static

Ensures that any exceptions thrown by the containing asynchronous method will be e-mailed and code will resume past this block

Template Parameters
TThe return type of the function
Parameters
emailThe implementation of the IEmail interface
appThe implementation of the IApplicationSettings interface
methodThe asynchronous method to execute which will have it's exceptions emailed
defaultValueIf an exception is thrown, this will be returned instead. Default = default(t). Eg. null for most classes
Returns
The return value from the calling method (or defaultValue)

◆ IgnoreException() [1/2]

static bool Sphyrnidae.Common.Utilities.SafeTry.IgnoreException ( Action  method)
static

Ensures that any exceptions thrown by the containing method will be handled gracefully and code will resume past this block

Parameters
methodThe method to execute which will have it's exceptions ignored
Returns
False if an exception was thrown, True if everything went off without exception

◆ IgnoreException() [2/2]

static async Task<bool> Sphyrnidae.Common.Utilities.SafeTry.IgnoreException ( Func< Task >  method)
static

Ensures that any exceptions thrown by the containing asynchronous method will be handled gracefully and code will resume past this block

Parameters
methodThe asynchronous method to execute which will have it's exceptions ignored
Returns
False if an exception was thrown, True if everything went off without exception

◆ IgnoreException< T >() [1/2]

static T Sphyrnidae.Common.Utilities.SafeTry.IgnoreException< T > ( Func< T >  method,
defaultValue = default 
)
static

Ensures that any exceptions thrown by the containing method will be handled gracefully and code will resume past this block

Template Parameters
TThe return type of the function
Parameters
methodThe method to execute which will have it's exceptions ignored
defaultValueIf an exception is thrown, this will be returned instead. Default = default(t). Eg. null for most classes
Returns
The return value from the calling method (or defaultValue)

◆ IgnoreException< T >() [2/2]

static async Task<T> Sphyrnidae.Common.Utilities.SafeTry.IgnoreException< T > ( Func< Task< T >>  method,
defaultValue = default 
)
static

Ensures that any exceptions thrown by the containing asynchronous method will be handled gracefully and code will resume past this block

Template Parameters
TThe return type of the function
Parameters
methodThe asynchronous method to execute which will have it's exceptions ignored
defaultValueIf an exception is thrown, this will be returned instead. Default = default(t). Eg. null for most classes
Returns
The return value from the calling method (or defaultValue)

◆ LogException() [1/2]

static bool Sphyrnidae.Common.Utilities.SafeTry.LogException ( ILogger  logger,
Action  method 
)
static

Ensures that any exceptions thrown by the containing method will be handled gracefully and code will resume past this block

If an exception occurs, it will be logged out as a hidden exception

Parameters
loggerThe implementation of the ILogger interface
methodThe method to execute which will have it's exceptions ignored
Returns
False if an exception was thrown, True if everything went off without exception

◆ LogException() [2/2]

static async Task<bool> Sphyrnidae.Common.Utilities.SafeTry.LogException ( ILogger  logger,
Func< Task >  method 
)
static

Ensures that any exceptions thrown by the containing asynchronous method will be handled gracefully and code will resume past this block

If an exception occurs, it will be logged out as a hidden exception

Parameters
loggerThe implementation of the ILogger interface
methodThe asynchronous method to execute which will have it's exceptions ignored
Returns
False if an exception was thrown, True if everything went off without exception

◆ LogException< T >() [1/2]

static T Sphyrnidae.Common.Utilities.SafeTry.LogException< T > ( ILogger  logger,
Func< T >  method,
defaultValue = default 
)
static

Ensures that any exceptions thrown by the containing method will be handled gracefully and code will resume past this block

If an exception occurs, it will be logged out as a hidden exception

Template Parameters
TThe return type of the function
Parameters
loggerThe ILogger implementation
methodThe method to execute which will have it's exceptions ignored
defaultValueIf an exception is thrown, this will be returned instead. Default = default(t). Eg. null for most classes
Returns
The return value from the calling method (or defaultValue)

◆ LogException< T >() [2/2]

static async Task<T> Sphyrnidae.Common.Utilities.SafeTry.LogException< T > ( ILogger  logger,
Func< Task< T >>  method,
defaultValue = default 
)
static

Ensures that any exceptions thrown by the containing asynchronous method will be handled gracefully and code will resume past this block

If an exception occurs, it will be logged out as a hidden exception

Template Parameters
TThe return type of the function
Parameters
loggerThe ILogger implementation
methodThe asynchronous method to execute which will have it's exceptions ignored
defaultValueIf an exception is thrown, this will be returned instead. Default = default(t). Eg. null for most classes
Returns
The return value from the calling method (or defaultValue)

◆ OnException() [1/4]

static bool Sphyrnidae.Common.Utilities.SafeTry.OnException ( Action  method,
Func< Exception, bool >  error 
)
static

Wrapper which executes a method safely, and allows the user to customize the exception handling

Parameters
methodThe method to execute which will have it's exceptions sent to error method
errorThe method to execute if the main method throws an exception
Returns
True if the main method succeeded, or True/False based on the exception method

◆ OnException() [2/4]

static Task<bool> Sphyrnidae.Common.Utilities.SafeTry.OnException ( Action  method,
Func< Exception, Task< bool >>  error 
)
static

Wrapper which executes a method safely, and allows the user to customize the exception handling asynchronously

Parameters
methodThe method to execute which will have it's exceptions sent to error method
errorThe asynchronous method to execute if the main method throws an exception
Returns
True if the main method succeeded, or True/False based on the exception method (awaitable)

◆ OnException() [3/4]

static async Task<bool> Sphyrnidae.Common.Utilities.SafeTry.OnException ( Func< Task >  method,
Func< Exception, bool >  error 
)
static

Wrapper which executes an asynchronous method safely, and allows the user to customize the exception handling

Parameters
methodThe asynchronous method to execute which will have it's exceptions sent to error method
errorThe method to execute if the main method throws an exception
Returns
True if the main method succeeded, or True/False based on the exception method (awaitable)

◆ OnException() [4/4]

static async Task<bool> Sphyrnidae.Common.Utilities.SafeTry.OnException ( Func< Task >  method,
Func< Exception, Task< bool >>  error 
)
static

Wrapper which executes an asynchronous method safely, and allows the user to customize the exception handling asynchronously

Parameters
methodThe asynchronous method to execute which will have it's exceptions sent to error method
errorThe asynchronous method to execute if the main method throws an exception
Returns
True if the main method succeeded, or True/False based on the exception method (awaitable)

◆ OnException< T >() [1/4]

static T Sphyrnidae.Common.Utilities.SafeTry.OnException< T > ( Func< T >  method,
Func< Exception, T >  error 
)
static

Wrapper which executes a method safely, and allows the user to customize the exception handling

Template Parameters
TThe return type of the function
Parameters
methodThe method to execute which will have it's exceptions sent to error method
errorThe method to execute if the main method throws an exception
Returns
The return from either the main method or the exception handler

◆ OnException< T >() [2/4]

static Task<T> Sphyrnidae.Common.Utilities.SafeTry.OnException< T > ( Func< T >  method,
Func< Exception, Task< T >>  error 
)
static

Wrapper which executes a method safely, and allows the user to customize the exception handling asynchronously

Template Parameters
TThe return type of the function
Parameters
methodThe method to execute which will have it's exceptions sent to error method
errorThe asynchronous method to execute if the main method throws an exception
Returns
The return from either the main method or the exception handler (awaitable)

◆ OnException< T >() [3/4]

static async Task<T> Sphyrnidae.Common.Utilities.SafeTry.OnException< T > ( Func< Task< T >>  method,
Func< Exception, T >  error 
)
static

Wrapper which executes an asynchronous method safely, and allows the user to customize the exception handling

Template Parameters
TThe return type of the function
Parameters
methodThe asynchronous method to execute which will have it's exceptions sent to error method
errorThe method to execute if the main method throws an exception
Returns
The return from either the main method or the exception handler (awaitable)

◆ OnException< T >() [4/4]

static async Task<T> Sphyrnidae.Common.Utilities.SafeTry.OnException< T > ( Func< Task< T >>  method,
Func< Exception, Task< T >>  error 
)
static

Wrapper which executes an asynchronous method safely, and allows the user to customize the exception handling asynchronously

Template Parameters
TThe return type of the function
Parameters
methodThe asynchronous method to execute which will have it's exceptions sent to error method
errorThe asynchronous method to execute if the main method throws an exception
Returns
The return from either the main method or the exception handler (awaitable)

The documentation for this class was generated from the following file: