mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
fix: Fix issue with some errors not being handled correctly (no-changelog) (#10371)
This commit is contained in:
@@ -167,7 +167,7 @@ export abstract class NodeError extends ExecutionBaseError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if code is provided and it is in the list of common errors set the message and return early
|
// if code is provided and it is in the list of common errors set the message and return early
|
||||||
if (code && COMMON_ERRORS[code.toUpperCase()]) {
|
if (code && typeof code === 'string' && COMMON_ERRORS[code.toUpperCase()]) {
|
||||||
newMessage = COMMON_ERRORS[code] as string;
|
newMessage = COMMON_ERRORS[code] as string;
|
||||||
messages.push(message);
|
messages.push(message);
|
||||||
return [newMessage, messages];
|
return [newMessage, messages];
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { INode } from '@/Interfaces';
|
import type { INode, JsonObject } from '@/Interfaces';
|
||||||
import { NodeOperationError } from '@/errors';
|
import { NodeOperationError } from '@/errors';
|
||||||
import { NodeApiError } from '@/errors/node-api.error';
|
import { NodeApiError } from '@/errors/node-api.error';
|
||||||
import { UNKNOWN_ERROR_DESCRIPTION, UNKNOWN_ERROR_MESSAGE } from '../src/Constants';
|
import { UNKNOWN_ERROR_DESCRIPTION, UNKNOWN_ERROR_MESSAGE } from '../src/Constants';
|
||||||
@@ -260,4 +260,22 @@ describe('NodeApiError message and description logic', () => {
|
|||||||
expect(nodeApiError.message).toEqual(UNKNOWN_ERROR_MESSAGE);
|
expect(nodeApiError.message).toEqual(UNKNOWN_ERROR_MESSAGE);
|
||||||
expect(nodeApiError.description).toEqual(UNKNOWN_ERROR_DESCRIPTION);
|
expect(nodeApiError.description).toEqual(UNKNOWN_ERROR_DESCRIPTION);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('case: Error code sent as "any"', () => {
|
||||||
|
const error = {
|
||||||
|
code: 400,
|
||||||
|
message: "Invalid value 'test' for viewId parameter.",
|
||||||
|
status: 'INVALID_ARGUMENT',
|
||||||
|
};
|
||||||
|
const [message, ...rest] = error.message.split('\n');
|
||||||
|
const description = rest.join('\n');
|
||||||
|
const httpCode = error.code as any;
|
||||||
|
const nodeApiError = new NodeApiError(node, error as JsonObject, {
|
||||||
|
message,
|
||||||
|
description,
|
||||||
|
httpCode,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(nodeApiError.message).toEqual(error.message);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user