SSE Session and examples
This commit is contained in:
@@ -37,3 +37,15 @@ export const isWithinBounds = (value: number, min: number, max: number): boolean
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a non-error to an error
|
||||
* @param error - The error to convert
|
||||
* @returns The error
|
||||
*/
|
||||
export const normalizeError = (error: unknown): Error => {
|
||||
// Convert the error to an error if it is not already an error
|
||||
const errorInstance = error instanceof Error ? error : new Error(`${error}`);
|
||||
|
||||
return errorInstance;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user