feat: Do not show errors not processed by n8n (no-changelog) (#9598)

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Michael Kret
2024-06-20 08:45:00 +03:00
committed by GitHub
parent 4740162232
commit b7aea957b8
317 changed files with 471 additions and 454 deletions

View File

@@ -100,3 +100,5 @@ export const SINGLE_EXECUTION_NODES: { [key: string]: { [key: string]: NodeParam
operation: [undefined], // default info
},
};
export const OBFUSCATED_ERROR_MESSAGE = 'Internal error';

View File

@@ -850,7 +850,7 @@ type FunctionsBaseWithRequiredKeys<Keys extends keyof FunctionsBase> = Functions
export type ContextType = 'flow' | 'node';
type BaseExecutionFunctions = FunctionsBaseWithRequiredKeys<'getMode'> & {
continueOnFail(): boolean;
continueOnFail(error?: Error): boolean;
evaluateExpression(expression: string, itemIndex: number): NodeParameterValueType;
getContext(type: ContextType): IContextObject;
getExecuteData(): IExecuteData;

View File

@@ -1,6 +1,8 @@
import type { INode, JsonObject } from '@/Interfaces';
import type { NodeOperationErrorOptions } from './node-api.error';
import { NodeError } from './abstract/node.error';
import { ApplicationError } from './application.error';
import { OBFUSCATED_ERROR_MESSAGE } from '../Constants';
/**
* Class for instantiating an operational error, e.g. an invalid credentials error.
@@ -16,8 +18,14 @@ export class NodeOperationError extends NodeError {
if (error instanceof NodeOperationError) {
return error;
}
let obfuscateErrorMessage = false;
if (typeof error === 'string') {
error = new Error(error);
} else if (!(error instanceof ApplicationError)) {
// this error was no processed by n8n, obfuscate error message
obfuscateErrorMessage = true;
}
super(node, error);
@@ -26,6 +34,7 @@ export class NodeOperationError extends NodeError {
error.messages.forEach((message) => this.addToMessages(message));
}
if (obfuscateErrorMessage) this.message = OBFUSCATED_ERROR_MESSAGE;
if (options.message) this.message = options.message;
if (options.level) this.level = options.level;
if (options.functionality) this.functionality = options.functionality;