@vsokolov/utils - v1.4.2
    Preparing search index...

    Interface TryCatchOptions<E>

    Configuration options for the tryCatch function.

    // Basic configuration
    { defaultStatus: 400 }

    // With custom error class
    { ErrorClass: ApiError, defaultStatus: 500 }
    interface TryCatchOptions<E extends Error = ErrorWithStatus> {
        defaultStatus?: number;
        ErrorClass?: ErrorConstructor<E>;
    }

    Type Parameters

    • E extends Error = ErrorWithStatus

      The type of error class to use for error transformation

    Index

    Properties

    defaultStatus?: number

    Default HTTP status code to use when caught error has no status property.

    500
    
    ErrorClass?: ErrorConstructor<E>

    Custom error class constructor for transforming caught errors. If provided, all caught errors will be converted to instances of this class.

    Error