fixed up logger error to make it better to handle in code
This commit is contained in:
parent
db66687f48
commit
d0bb4db042
18 changed files with 51 additions and 45 deletions
|
|
@ -135,8 +135,12 @@ export class Logger {
|
|||
this.log('warn', message, metadata);
|
||||
}
|
||||
|
||||
error(message: string | object, metadata?: LogMetadata & { error?: any }): void {
|
||||
const data = { ...metadata };
|
||||
error(message: string | object, metadata?: LogMetadata & { error?: any } | unknown): void {
|
||||
// If metadata is an Error, normalize it
|
||||
if(metadata instanceof Error){
|
||||
metadata = { error: metadata };
|
||||
}
|
||||
const data = typeof metadata === 'object' ? { ...metadata } : { error: message } as any;
|
||||
|
||||
// Handle any type of error automatically
|
||||
if (data.error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue