mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
fix: Fix issue with some errors not being handled correctly (no-changelog) (#10371)
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
This commit is contained in:
parent
8e7d29ad3c
commit
1e310f40f7
|
@ -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 && COMMON_ERRORS[code.toUpperCase()]) {
|
||||
if (code && typeof code === 'string' && COMMON_ERRORS[code.toUpperCase()]) {
|
||||
newMessage = COMMON_ERRORS[code] as string;
|
||||
messages.push(message);
|
||||
return [newMessage, messages];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { INode } from '@/Interfaces';
|
||||
import type { INode, JsonObject } from '@/Interfaces';
|
||||
import { NodeOperationError } from '@/errors';
|
||||
import { NodeApiError } from '@/errors/node-api.error';
|
||||
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.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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue