Show / Hide Table of Contents

    Class ExceptionUtility

    This utility class is designed to make exception operations more flexible and easier to work with.

    Inheritance
    System.Object
    ExceptionUtility
    Namespace: Cuemon
    Assembly: Cuemon.Core.dll
    Syntax
    public static class ExceptionUtility

    Methods

    | Improve this Doc

    CreateArgumentEmptyException(String, String)

    Creates and returns a new ArgumentEmptyException initialized to the provided parameters.

    Declaration
    public static ArgumentEmptyException CreateArgumentEmptyException(string paramName, string message)
    Parameters
    Type Name Description
    System.String paramName

    The name of the parameter that caused the exception.

    System.String message

    A message that describes the error.

    Returns
    Type Description
    ArgumentEmptyException

    A new instance of ArgumentEmptyException initialized to the provided parameters.

    | Improve this Doc

    CreateArgumentException(String, String)

    Creates and returns a new System.ArgumentException initialized to the provided parameters.

    Declaration
    public static ArgumentException CreateArgumentException(string paramName, string message)
    Parameters
    Type Name Description
    System.String paramName

    The name of the parameter that caused the exception.

    System.String message

    A message that describes the error.

    Returns
    Type Description
    System.ArgumentException

    A new instance of System.ArgumentException initialized to the provided parameters.

    | Improve this Doc

    CreateArgumentException(String, String, Exception)

    Creates and returns a new System.ArgumentException initialized to the provided parameters.

    Declaration
    public static ArgumentException CreateArgumentException(string paramName, string message, Exception innerException)
    Parameters
    Type Name Description
    System.String paramName

    The name of the parameter that caused the exception.

    System.String message

    A message that describes the error.

    System.Exception innerException

    The exception that is the cause of the current exception. If the innerException parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception.

    Returns
    Type Description
    System.ArgumentException

    A new instance of System.ArgumentException initialized to the provided parameters.

    | Improve this Doc

    CreateArgumentNullException(String, String)

    Creates and returns a new System.ArgumentNullException initialized to the provided parameters.

    Declaration
    public static ArgumentNullException CreateArgumentNullException(string paramName, string message)
    Parameters
    Type Name Description
    System.String paramName

    The name of the parameter that caused the exception.

    System.String message

    A message that describes the error.

    Returns
    Type Description
    System.ArgumentNullException

    A new instance of System.ArgumentNullException initialized to the provided parameters.

    | Improve this Doc

    CreateArgumentOutOfRangeException(String, String)

    Creates and returns a new System.ArgumentOutOfRangeException initialized to the provided parameters.

    Declaration
    public static ArgumentOutOfRangeException CreateArgumentOutOfRangeException(string paramName, string message)
    Parameters
    Type Name Description
    System.String paramName

    The name of the parameter that caused the exception.

    System.String message

    A message that describes the error.

    Returns
    Type Description
    System.ArgumentOutOfRangeException

    A new instance of System.ArgumentOutOfRangeException initialized to the provided parameters.

    | Improve this Doc

    CreateTypeArgumentException(String, String)

    Creates and returns a new TypeArgumentException initialized to the provided parameters.

    Declaration
    public static TypeArgumentException CreateTypeArgumentException(string typeParamName, string message)
    Parameters
    Type Name Description
    System.String typeParamName

    The name of the type parameter that caused the exception.

    System.String message

    A message that describes the error.

    Returns
    Type Description
    TypeArgumentException

    A new instance of TypeArgumentException initialized to the provided parameters.

    | Improve this Doc

    CreateTypeArgumentOutOfRangeException(String, String)

    Creates and returns a new TypeArgumentOutOfRangeException initialized to the provided parameters.

    Declaration
    public static TypeArgumentOutOfRangeException CreateTypeArgumentOutOfRangeException(string typeParamName, string message)
    Parameters
    Type Name Description
    System.String typeParamName

    The name of the type parameter that caused the exception.

    System.String message

    A message that describes the error.

    Returns
    Type Description
    TypeArgumentOutOfRangeException

    A new instance of TypeArgumentOutOfRangeException initialized to the provided parameters.

    | Improve this Doc

    Flatten(Exception)

    Flattens any inner exceptions descendant-or-self from the specified exception into an System.Collections.Generic.IEnumerable<T> sequence of exceptions.

    Declaration
    public static IEnumerable<Exception> Flatten(Exception exception)
    Parameters
    Type Name Description
    System.Exception exception

    The exception to flatten.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.Exception>

    An empty System.Collections.Generic.IEnumerable<T> sequence if no inner exceptions was specified; otherwise any inner exceptions rooted to the specified exception as well as it's descendants.

    Remarks

    If any inner exceptions are referenced this method will iterative flatten all of them descendant-or-self from the specified exception.
    Should the exception be of the new AggregateException type introduced with .NET 4.0, the return sequence of this method will be equal to the result of the InnerExceptions property.

    Exceptions
    Type Condition
    System.ArgumentNullException

    exception is null.

    | Improve this Doc

    Flatten(Exception, Type)

    Flattens any inner exceptions descendant-or-self from the specified exception into an System.Collections.Generic.IEnumerable<T> sequence of exceptions.

    Declaration
    public static IEnumerable<Exception> Flatten(Exception exception, Type exceptionType)
    Parameters
    Type Name Description
    System.Exception exception

    The exception to flatten.

    System.Type exceptionType

    The type of the specified exception.

    Returns
    Type Description
    System.Collections.Generic.IEnumerable<System.Exception>

    An empty System.Collections.Generic.IEnumerable<T> sequence if no inner exceptions was referenced; otherwise any inner exceptions descendant-or-self from the specified exception.

    Remarks

    If any inner exceptions are referenced this method will iterative flatten all of them descendant-or-self from the specified exception.
    Should the exception be of the new AggregateException type introduced with .NET 4.0, the return sequence of this method will be equal to the result of the InnerExceptions property.

    Exceptions
    Type Condition
    System.ArgumentNullException

    exception -or exceptionType is null.

    | Improve this Doc

    Parse<TResult>(IEnumerable<Exception>)

    Parses the specified exceptions for a match on TResult.

    Declaration
    public static TResult Parse<TResult>(IEnumerable<Exception> exceptions)
        where TResult : Exception
    Parameters
    Type Name Description
    System.Collections.Generic.IEnumerable<System.Exception> exceptions

    A sequence of exceptions to parse for a match on TResult.

    Returns
    Type Description
    TResult

    The first matched System.Exception of TResult from the sequence of exceptions or null if no match could be resolved.

    Type Parameters
    Name Description
    TResult

    The type of the System.Exception to find a match within exceptions.

    Exceptions
    Type Condition
    System.ArgumentNullException

    exceptions is null.

    | Improve this Doc

    Parse<TResult>(Exception)

    Parses the specified exception for a match on TResult.

    Declaration
    public static TResult Parse<TResult>(Exception exception)
        where TResult : Exception
    Parameters
    Type Name Description
    System.Exception exception

    The exception to parse for a match on TResult.

    Returns
    Type Description
    TResult

    The matched exception cast as TResult or null if no match could be resolved.

    Type Parameters
    Name Description
    TResult

    The type of the exception to find a match on.

    Exceptions
    Type Condition
    System.ArgumentNullException

    exception is null.

    | Improve this Doc

    Refine(Exception, MethodDescriptor, Object[])

    Refines the specified exception with valuable meta information extracted from the associated method and parameters.

    Declaration
    public static MethodWrappedException Refine(Exception exception, MethodDescriptor method, params object[] parameters)
    Parameters
    Type Name Description
    System.Exception exception

    The exception that needs to be thrown.

    MethodDescriptor method

    The method signature containing valuable meta information.

    System.Object[] parameters

    The optional parameters to accompany method.

    Returns
    Type Description
    MethodWrappedException

    The specified exception refined with valuable meta information within a MethodWrappedException.

    Exceptions
    Type Condition
    System.ArgumentNullException

    exception is null - or - method is null.

    | Improve this Doc

    Refine(Exception, MethodBase, Object[])

    Refines the specified exception with valuable meta information extracted from the associated method and parameters.

    Declaration
    public static MethodWrappedException Refine(Exception exception, MethodBase method, params object[] parameters)
    Parameters
    Type Name Description
    System.Exception exception

    The exception that needs to be thrown.

    System.Reflection.MethodBase method

    The method to extract valuable meta information from.

    System.Object[] parameters

    The optional parameters to accompany method.

    Returns
    Type Description
    MethodWrappedException

    The specified exception refined with valuable meta information within a MethodWrappedException.

    Exceptions
    Type Condition
    System.ArgumentNullException

    exception is null - or - method is null.

    | Improve this Doc

    Unwrap(MethodWrappedException)

    Unwraps the specified wrappedException and returns the originating exception.

    Declaration
    public static Exception Unwrap(MethodWrappedException wrappedException)
    Parameters
    Type Name Description
    MethodWrappedException wrappedException

    The wrapped exception to unwrap.

    Returns
    Type Description
    System.Exception

    The originating exception from within MethodWrappedException.

    Exceptions
    Type Condition
    System.ArgumentNullException

    wrappedException is null.

    • Improve this Doc
    • View Source
    Back to top Copyright 2008-2018 Weubphoria. All rights reserved.
    Generated by DocFX