• Converts names like "ILLEGAL_STATE_ERROR" to methods illegalStateError at given constructor.

    Note: This should only be used by custom Exception classes. It is exported as extra name!

    Type Parameters

    • ExceptionType
    • AllowedNames
    • Name extends string | number | symbol

    Parameters

    • exceptionConstructor: BaseExceptionConstructor<ExceptionType, AllowedNames>

      the exception constructor.

    • ...names: Name[]

      the exception names to register.

    Returns void

     import {default as Exception, registerTypes} from "apprt-core/Exception";

    // register new exception type
    registerTypes(Exception, "ILLEGAL_STATE_ERROR");
    // now clients can invoke
    const e = Exception.illegalStateError("error message");
    e.name === 'ILLEGAL_STATE_ERROR';
    e.message === "error message";