refactor(logging): replace console usage in auth flows
This commit is contained in:
15
utils/error.ts
Normal file
15
utils/error.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
export const normalizeError = (error: unknown): Error => {
|
||||
if (error instanceof Error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
if (typeof error === 'string') {
|
||||
return new Error(error);
|
||||
}
|
||||
|
||||
try {
|
||||
return new Error(JSON.stringify(error));
|
||||
} catch {
|
||||
return new Error('Unknown error');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user