Skip to content

Commit

Permalink
feat: keep original error on context
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMaz committed Oct 17, 2024
1 parent d333d80 commit 7af0d12
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ export interface LoggerSentryExtrasInterface
> {
statusCode?: number;
message?: string | unknown;
originalError?: Error | string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ describe('loggerSentryTransport', () => {
level: 'error',
extra: {
developerMessage: errorMessage,
message: '',
originalError: error.stack,
},
});
});
Expand All @@ -128,7 +126,6 @@ describe('loggerSentryTransport', () => {
level: 'error',
extra: {
developerMessage: errorMessage,
message: error,
},
});
});
Expand Down Expand Up @@ -187,9 +184,7 @@ describe('loggerSentryTransport', () => {
statusCode: exception?.httpStatus,
message: exception?.message,
safeMessage: exception?.safeMessage,
originalError: exception?.context?.originalError,
context: exception?.context,

},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ export class LoggerSentryTransport implements LoggerTransportInterface {
this.handleHttpException(exception, extras);
} else if (exception instanceof RuntimeException) {
this.handleRuntimeException(exception, extras);
} else if (exception instanceof Error) {
this.handleError(exception, extras);
} else if (typeof exception === 'string') {
this.handleStringException(exception, extras);
}

return extras;
Expand All @@ -108,22 +104,6 @@ export class LoggerSentryTransport implements LoggerTransportInterface {
extras.statusCode = exception?.httpStatus;
extras.message = exception?.message;
extras.safeMessage = exception?.safeMessage;
extras.originalError = exception?.context?.originalError;
extras.context = exception?.context;
}

private handleError(
exception: Error,
extras: LoggerSentryExtrasInterface,
): void {
extras.message = exception?.message;
extras.originalError = exception?.stack || '';
}

private handleStringException(
exception: string,
extras: LoggerSentryExtrasInterface,
): void {
extras.message = exception;
}
}

0 comments on commit 7af0d12

Please sign in to comment.