Class ThrowHelper
- Namespace
- Garyon.Exceptions
- Assembly
- Garyon.dll
A helper class providing tools for throwing exceptions. It should be preferred to use in code that demands optimization.
public static class ThrowHelper
- Inheritance
-
ThrowHelper
- Inherited Members
Methods
Throw(Exception)
Throws an exception whose instance is already created.
public static Exception Throw(Exception e)
Parameters
eExceptionThe exception instance to throw.
Returns
- Exception
Never reaches the point of returning; the return type is so that an object can be used in return or throw statements (latter is not recommended).
ThrowAggregate(string, params Exception[])
Throws a new AggregateException.
public static Exception ThrowAggregate(string message, params Exception[] innerExceptions)
Parameters
messagestringThe error message that explains the reason for the exception.
innerExceptionsException[]The exceptions that are the cause of the current exception.
Returns
- Exception
Never reaches the point of returning; the return type is so that an object can be used in return or throw statements (latter is not recommended).
ThrowAggregate<T>(string, IEnumerable<Exception>)
Throws a new aggregate exception of the type T.
[DoesNotReturn]
public static T ThrowAggregate<T>(string message, IEnumerable<Exception> innerExceptions) where T : AggregateException
Parameters
messagestringThe error message that explains the reason for the exception.
innerExceptionsIEnumerable<Exception>The exceptions that are the cause of the current exception.
Returns
- T
Never reaches the point of returning; the return type is so that an object can be used in return or throw statements (latter is not recommended).
Type Parameters
TThe exception type to throw.
ThrowAggregate<T>(string, params Exception[])
Throws a new aggregate exception of the type T.
[DoesNotReturn]
public static T ThrowAggregate<T>(string message, params Exception[] innerExceptions) where T : AggregateException
Parameters
messagestringThe error message that explains the reason for the exception.
innerExceptionsException[]The exceptions that are the cause of the current exception.
Returns
- T
Never reaches the point of returning; the return type is so that an object can be used in return or throw statements (latter is not recommended).
Type Parameters
TThe exception type to throw.
Throw<T>()
Throws a new exception of the type T.
[DoesNotReturn]
public static T Throw<T>() where T : Exception, new()
Returns
- T
Never reaches the point of returning; the return type is so that an object can be used in return or throw statements (latter is not recommended).
Type Parameters
TThe exception type to throw.
Throw<T>(string)
Throws a new exception of the type T.
[DoesNotReturn]
public static T Throw<T>(string message) where T : Exception
Parameters
messagestringThe error message that explains the reason for the exception.
Returns
- T
Never reaches the point of returning; the return type is so that an object can be used in return or throw statements (latter is not recommended).
Type Parameters
TThe exception type to throw.
Throw<T>(string, Exception)
Throws a new exception of the type T.
[DoesNotReturn]
public static T Throw<T>(string message, Exception innerException) where T : Exception
Parameters
messagestringThe error message that explains the reason for the exception.
innerExceptionExceptionThe exception that is the cause of the current exception, or a null reference if no inner exception is specified.
Returns
- T
Never reaches the point of returning; the return type is so that an object can be used in return or throw statements (latter is not recommended).
Type Parameters
TThe exception type to throw.