Skip to content
On this page

@shaggytools/nhtsa-api-wrapper - v3.0.4 / Exports / utils/errorHandler

Module: utils/errorHandler

Table of contents

Functions

Functions

handleError

handleError(error): Error

Handles errors by returning an Error instance. Accepts any type of value but will return default error message of an unknown error occurred if error is not an Error type or a message string.

Parameters

NameTypeDescription
errorunknownAny type of value

Returns

Error

  • instance of Error with message

Defined in

utils/errorHandler.ts:26


isError

isError(error): boolean

Checks if error is an instance of any Error type.

Parameters

NameTypeDescription
errorunknownAny type of value

Returns

boolean

  • True if error is an instance of Error, TypeError, etc.

Defined in

utils/errorHandler.ts:14


rejectWithError

rejectWithError(error): Promise<never>

Returns a Promise rejection containing an Error instance. Uses handleError to return a default error message if error is not an Error type.

Parameters

NameTypeDescription
errorunknownAny type of value

Returns

Promise<never>

Defined in

utils/errorHandler.ts:47

Released under the MIT License.