feat(core): Reduce the number of events sent to Sentry (#6235)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-05-15 13:54:48 +00:00
committed by GitHub
parent 9182d1558a
commit a4c0cc9b5c
5 changed files with 49 additions and 9 deletions

View File

@@ -9,6 +9,8 @@
import { parseString } from 'xml2js';
import type { IDataObject, INode, IStatusCodeMessages, JsonObject } from './Interfaces';
type Severity = 'warning' | 'error';
/**
* Top-level properties where an error message can be found in an API response.
*/
@@ -103,9 +105,11 @@ export abstract class ExecutionBaseError extends Error {
* Base class for specific NodeError-types, with functionality for finding
* a value recursively inside an error object.
*/
abstract class NodeError extends ExecutionBaseError {
export abstract class NodeError extends ExecutionBaseError {
node: INode;
severity: Severity = 'error';
constructor(node: INode, error: Error | JsonObject) {
const message = error instanceof Error ? error.message : '';
super(message, { cause: error });
@@ -234,6 +238,7 @@ interface NodeOperationErrorOptions {
description?: string;
runIndex?: number;
itemIndex?: number;
severity?: Severity;
}
/**
@@ -248,9 +253,8 @@ export class NodeOperationError extends NodeError {
}
super(node, error);
if (options.message) {
this.message = options.message;
}
if (options.message) this.message = options.message;
if (options.severity) this.severity = options.severity;
this.description = options.description;
this.context.runIndex = options.runIndex;
this.context.itemIndex = options.itemIndex;
@@ -296,10 +300,21 @@ export class NodeApiError extends NodeError {
constructor(
node: INode,
error: JsonObject,
{ message, description, httpCode, parseXml, runIndex, itemIndex }: NodeApiErrorOptions = {},
{
message,
description,
httpCode,
parseXml,
runIndex,
itemIndex,
severity,
}: NodeApiErrorOptions = {},
) {
super(node, error);
if (severity) this.severity = severity;
else if (httpCode?.charAt(0) !== '5') this.severity = 'warning';
if (error.error) {
// only for request library error
this.removeCircularRefs(error.error as JsonObject);

View File

@@ -217,11 +217,13 @@ export class RoutingNode {
returnData.push({ json: {}, error: error.message });
continue;
}
if (error instanceof NodeApiError) error = error.cause;
throw new NodeApiError(this.node, error, {
runIndex,
itemIndex: i,
message: error?.message,
description: error?.description,
httpCode: error.isAxiosError && error.response && String(error.response?.status),
});
}
}