@shaggytools/nhtsa-api-wrapper
Version:
Universal javascript wrapper for the NHTSA.dot.gov VPIC 'vehicles' API, useful for VIN decoding, etc.
29 lines • 980 B
TypeScript
/**
* @module utils/errorHandler
* @category Utility Functions
*/
/**
* Checks if `error` is an instance of any Error type.
*
* @param error - Any type of value
* @returns - True if `error` is an instance of Error, TypeError, etc.
*/
export declare const isError: (error: unknown) => boolean;
/**
* 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.
*
* @param error - Any type of value
* @returns - instance of Error with message
*/
export declare const handleError: (error: unknown) => Error;
/**
* Returns a Promise rejection containing an Error instance.
* Uses {@link handleError} to return a default error message if `error` is
* not an Error type.
*
* @param error - Any type of value
*/
export declare const rejectWithError: (error: unknown) => Promise<never>;
//# sourceMappingURL=errorHandler.d.ts.map