mirror of
https://github.com/jeffvli/feishin.git
synced 2024-11-20 14:37:06 +01:00
Remove throw from log function
- Typescript cannot determine if a function throws an error - Does not work as a type guard when using ts-rest
This commit is contained in:
parent
509627a0ad
commit
3b155cc6e8
@ -1,4 +1,3 @@
|
||||
import console from 'console';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const reset = '\x1b[0m';
|
||||
@ -23,19 +22,10 @@ const baseLog = (errorType: 'error' | 'info' | 'success' | 'warn') => {
|
||||
break;
|
||||
}
|
||||
|
||||
return (
|
||||
text: string,
|
||||
options?: { context?: Record<string, any>; throwError?: boolean; toast?: boolean },
|
||||
): null | Error => {
|
||||
const { throwError } = options || {};
|
||||
return (text: string, options?: { context?: Record<string, any>; toast?: boolean }): void => {
|
||||
// const { toast } = options || {};
|
||||
const now = dayjs().toISOString();
|
||||
console.log(`${logString}${now}${text}${JSON.stringify(options?.context)}${reset}`);
|
||||
|
||||
if (!throwError) {
|
||||
return null;
|
||||
}
|
||||
|
||||
throw new Error(text);
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user