@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
Name | Type | Description |
---|---|---|
error | unknown | Any type of value |
Returns
Error
- instance of Error with message
Defined in
isError
▸ isError(error
): boolean
Checks if error
is an instance of any Error type.
Parameters
Name | Type | Description |
---|---|---|
error | unknown | Any type of value |
Returns
boolean
- True if
error
is an instance of Error, TypeError, etc.
Defined in
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
Name | Type | Description |
---|---|---|
error | unknown | Any type of value |
Returns
Promise
<never
>