Set up a scratch pad.

This commit is contained in:
Steve Kinney
2024-09-29 12:57:06 -06:00
parent 56eadb7f93
commit 7810e6ae54
10 changed files with 34 additions and 123 deletions

View File

@@ -1,16 +0,0 @@
/**
*
* @param {unknown} error The error object to check.
* @returns {error is Error}
*/
export const isError = (error) => error instanceof Error;
/**
* Get the error message from an error object or return a default message.
* @param {unknown} error The error object to check.
* @param {string} defaultMessage The default message to return if the error is not an instance of Error.
* @returns {string} The error message or the default message.
*/
export const getErrorMessage = (error, defaultMessage) => {
return isError(error) ? error.message : defaultMessage;
};