ChemPal Documentation - v1.18.0
    Preparing search index...

    Module helpers/exceptions

    Classes - Exceptions

    EmptyResponseError

    Error thrown when a response is empty.

    HttpError

    Error thrown when an HTTP response has a non-2xx status. Carries the numeric status so callers can branch on it (e.g. retrying a 403 WAF cookie challenge) rather than string-matching the message.

    Functions - Exceptions

    getErrorMessage

    Reads a human-readable message from anything that can be thrown. A catch variable is typed unknown, so error.message doesn't type-check; this narrows it safely. Used to put the cause in a logger call's message (see the last example).

    isAbortError

    True for an AbortError, the error a cancelled fetch rejects with. A user stop or a search-budget timeout is expected and must not be treated as a supplier failure.

    isExpectedAbort

    True when something stopped because the search was deliberately aborted: an AbortError, or one of the bare SEARCH_ABORT_REASON strings that a fetch rejects with when controller.abort(reason) is given a string. Use it to log such stops at debug.

    isRateLimited

    True when a supplier answered 429 Too Many Requests. That is the supplier throttling us, not a bug here, so callers log it at warn instead of error.