qfetch
    Preparing search index...

    Type Alias ResponseErrorOptions

    Configuration options for the withResponseError middleware.

    All options are optional, allowing zero-config usage that throws ResponseError for any response with status code >= 400.

    type ResponseErrorOptions = {
        defaultMapper?: ResponseErrorMapper;
        statusMap?: Map<number, ResponseErrorMapper>;
        throwOnStatusCode?: (code: number) => boolean;
    }
    Index

    Properties

    defaultMapper?: ResponseErrorMapper

    Creates errors for status codes not in statusMap.

    (response) => new ResponseError(response)
    
    statusMap?: Map<number, ResponseErrorMapper>

    Maps specific status codes to custom error mappers.

    When a response matches a status code in this map, the corresponding mapper function is called to create the error. This takes priority over defaultMapper.

    statusMap: new Map([
    [404, (res) => new NotFoundError(res.url)],
    [401, async (res) => new AuthError(await res.json())]
    ])
    throwOnStatusCode?: (code: number) => boolean

    Determines whether to throw for a given status code.

    (code) => code >= 400