mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
fix(core): Deduplicate error handling in nodes (#4319)
* Fix issue with isAxios property * 🥅 Deduplicate errors handeling improve errors for credentials * 🎨 correctly throws error
This commit is contained in:
@@ -255,9 +255,12 @@ const STATUS_CODE_MESSAGES: IStatusCodeMessages = {
|
||||
'502': 'Bad gateway - the service failed to handle your request',
|
||||
'503': 'Service unavailable - perhaps try again later?',
|
||||
'504': 'Gateway timed out - perhaps try again later?',
|
||||
|
||||
ECONNREFUSED: 'The service refused the connection - perhaps it is offline',
|
||||
};
|
||||
|
||||
const UNKNOWN_ERROR_MESSAGE = 'UNKNOWN ERROR - check the detailed error for more information';
|
||||
const UNKNOWN_ERROR_MESSAGE_CRED = 'UNKNOWN ERROR';
|
||||
|
||||
interface NodeApiErrorOptions extends NodeOperationErrorOptions {
|
||||
message?: string;
|
||||
@@ -282,10 +285,14 @@ export class NodeApiError extends NodeError {
|
||||
// only for request library error
|
||||
this.removeCircularRefs(error.error as JsonObject);
|
||||
}
|
||||
|
||||
// if it's an error generated by axios
|
||||
// look for descriptions in the response object
|
||||
if (error.isAxiosError && error.response) {
|
||||
error = error.response as JsonObject;
|
||||
if (error.reason) {
|
||||
const reason: IDataObject = error.reason as unknown as IDataObject;
|
||||
if (reason.isAxiosError && reason.response) {
|
||||
error = reason.response as JsonObject;
|
||||
}
|
||||
}
|
||||
|
||||
if (message) {
|
||||
@@ -351,5 +358,8 @@ export class NodeApiError extends NodeError {
|
||||
default:
|
||||
this.message = UNKNOWN_ERROR_MESSAGE;
|
||||
}
|
||||
if (this.node.type === 'n8n-nodes-base.noOp' && this.message === UNKNOWN_ERROR_MESSAGE) {
|
||||
this.message = `${UNKNOWN_ERROR_MESSAGE_CRED} - ${this.httpCode}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user