refactor messaging error handling (#15416)
This commit is contained in:
+20
@@ -9,6 +9,7 @@ import { type ExceptionHandlerOptions } from 'src/engine/core-modules/exception-
|
||||
|
||||
import { PostgresException } from 'src/engine/api/graphql/workspace-query-runner/utils/postgres-exception';
|
||||
import { type ExceptionHandlerDriverInterface } from 'src/engine/core-modules/exception-handler/interfaces';
|
||||
import { MessageImportDriverException } from 'src/modules/messaging/message-import-manager/drivers/exceptions/message-import-driver.exception';
|
||||
import { CustomException } from 'src/utils/custom-exception';
|
||||
|
||||
export class ExceptionHandlerSentryDriver
|
||||
@@ -61,6 +62,20 @@ export class ExceptionHandlerSentryDriver
|
||||
});
|
||||
}
|
||||
|
||||
if ('context' in exception && exception.context) {
|
||||
Object.entries(exception.context).forEach(([key, value]) => {
|
||||
scope.setExtra(key, value);
|
||||
});
|
||||
}
|
||||
|
||||
if ('cause' in exception && exception.cause) {
|
||||
scope.setContext('cause', {
|
||||
name: exception.cause.name,
|
||||
message: exception.cause.message,
|
||||
stack: exception.cause.stack,
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
exception instanceof CustomException &&
|
||||
exception.code !== 'UNKNOWN'
|
||||
@@ -84,6 +99,11 @@ export class ExceptionHandlerSentryDriver
|
||||
exception.name = exception.message;
|
||||
}
|
||||
|
||||
if (exception instanceof MessageImportDriverException) {
|
||||
scope.setTag('messageImportDriverCode', exception.code);
|
||||
scope.setFingerprint([exception.code]);
|
||||
}
|
||||
|
||||
const eventId = Sentry.captureException(exception, {
|
||||
contexts: {
|
||||
GraphQL: {
|
||||
|
||||
Reference in New Issue
Block a user