From 7af0d12dbecd34f8a9b4e8280413e90af7a27943 Mon Sep 17 00:00:00 2001 From: Marshall Sorenson Date: Thu, 17 Oct 2024 17:44:53 -0400 Subject: [PATCH] feat: keep original error on context --- .../logger-sentry-extras.interface.ts | 1 - .../logger-sentry.transport.spec.ts | 5 ----- .../src/transports/logger-sentry.transport.ts | 20 ------------------- 3 files changed, 26 deletions(-) diff --git a/packages/nestjs-logger-sentry/src/interfaces/logger-sentry-extras.interface.ts b/packages/nestjs-logger-sentry/src/interfaces/logger-sentry-extras.interface.ts index 74a4aa80..b2d7bba4 100644 --- a/packages/nestjs-logger-sentry/src/interfaces/logger-sentry-extras.interface.ts +++ b/packages/nestjs-logger-sentry/src/interfaces/logger-sentry-extras.interface.ts @@ -6,5 +6,4 @@ export interface LoggerSentryExtrasInterface > { statusCode?: number; message?: string | unknown; - originalError?: Error | string; } diff --git a/packages/nestjs-logger-sentry/src/transports/logger-sentry.transport.spec.ts b/packages/nestjs-logger-sentry/src/transports/logger-sentry.transport.spec.ts index 0d6b7050..a88532cc 100644 --- a/packages/nestjs-logger-sentry/src/transports/logger-sentry.transport.spec.ts +++ b/packages/nestjs-logger-sentry/src/transports/logger-sentry.transport.spec.ts @@ -107,8 +107,6 @@ describe('loggerSentryTransport', () => { level: 'error', extra: { developerMessage: errorMessage, - message: '', - originalError: error.stack, }, }); }); @@ -128,7 +126,6 @@ describe('loggerSentryTransport', () => { level: 'error', extra: { developerMessage: errorMessage, - message: error, }, }); }); @@ -187,9 +184,7 @@ describe('loggerSentryTransport', () => { statusCode: exception?.httpStatus, message: exception?.message, safeMessage: exception?.safeMessage, - originalError: exception?.context?.originalError, context: exception?.context, - }, }); }); diff --git a/packages/nestjs-logger-sentry/src/transports/logger-sentry.transport.ts b/packages/nestjs-logger-sentry/src/transports/logger-sentry.transport.ts index 5227162f..166bd342 100644 --- a/packages/nestjs-logger-sentry/src/transports/logger-sentry.transport.ts +++ b/packages/nestjs-logger-sentry/src/transports/logger-sentry.transport.ts @@ -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; @@ -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; - } }