Interface of the exception constructor.

interface ExceptionConstructor {
    new ExceptionConstructor(
        name: string,
        message?: string,
        cause?: Error | Exception,
    ): Exception;
    illegalArgumentError(message: string, cause?: Error | Exception): Exception;
    illegalStateError(message: string, cause?: Error | Exception): Exception;
    notImplemented(message: string, cause?: Error | Exception): Exception;
    unknown(message: string, cause?: Error | Exception): Exception;
    wrap(error: Error | Exception, msg?: string): Exception;
    wrap(error: string): Exception;
}

Hierarchy

  • BaseExceptionConstructor<Exception, typeof ExceptionNames>
    • ExceptionConstructor

Constructors

  • Creates an Exception. For internal use only! Please use the factory methods, to create an Exception!

    Parameters

    • name: string

      The type name, the default is UNKNOWN.

    • Optionalmessage: string

      The associated message.

    • Optionalcause: Error | Exception

      The cause of this exception.

    Returns Exception

Methods

  • Factory method for Exceptions of type 'ILLEGAL_ARGUMENT_ERROR'

    Parameters

    • message: string
    • Optionalcause: Error | Exception

    Returns Exception

  • Factory method for Exceptions of type 'ILLEGAL_STATE_ERROR'

    Parameters

    • message: string
    • Optionalcause: Error | Exception

    Returns Exception

  • Factory method for Exceptions of type 'NOT_IMPLEMENTED'

    Parameters

    • message: string
    • Optionalcause: Error | Exception

    Returns Exception

  • Factory method for Exceptions of type 'UNKNOWN'

    Parameters

    • message: string
    • Optionalcause: Error | Exception

    Returns Exception

  • Wraps errors into Exceptions to get correct stacktraces.

    Parameters

    • error: Error | Exception

      the error

    • Optionalmsg: string

      the error message

    Returns Exception

    import Exception from "apprt-core/Exception";

    try {
    // code with throws an error
    } catch(e) {
    // wrap into exception class to get stacktraces
    throw Exception.wrap(e);
    }
  • Wraps errors into Exceptions to get correct stacktraces.

    Parameters

    • error: string

      the error message

    Returns Exception