mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix: Error processing and output pane improvements (no-changelog) (#9626)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -39,8 +39,9 @@ interface NodeApiErrorOptions extends NodeOperationErrorOptions {
|
||||
|
||||
/**
|
||||
* Top-level properties where an error message can be found in an API response.
|
||||
* order is important, precedence is from top to bottom
|
||||
*/
|
||||
const ERROR_MESSAGE_PROPERTIES = [
|
||||
const POSSIBLE_ERROR_MESSAGE_KEYS = [
|
||||
'cause',
|
||||
'error',
|
||||
'message',
|
||||
@@ -60,6 +61,7 @@ const ERROR_MESSAGE_PROPERTIES = [
|
||||
'errorDescription',
|
||||
'error_description',
|
||||
'error_summary',
|
||||
'error_info',
|
||||
'title',
|
||||
'text',
|
||||
'field',
|
||||
@@ -67,10 +69,15 @@ const ERROR_MESSAGE_PROPERTIES = [
|
||||
'type',
|
||||
];
|
||||
|
||||
/**
|
||||
* Properties where a nested object can be found in an API response.
|
||||
*/
|
||||
const POSSIBLE_NESTED_ERROR_OBJECT_KEYS = ['Error', 'error', 'err', 'response', 'body', 'data'];
|
||||
|
||||
/**
|
||||
* Top-level properties where an HTTP error code can be found in an API response.
|
||||
*/
|
||||
const ERROR_STATUS_PROPERTIES = [
|
||||
const POSSIBLE_ERROR_STATUS_KEYS = [
|
||||
'statusCode',
|
||||
'status',
|
||||
'code',
|
||||
@@ -79,11 +86,6 @@ const ERROR_STATUS_PROPERTIES = [
|
||||
'error_code',
|
||||
];
|
||||
|
||||
/**
|
||||
* Properties where a nested object can be found in an API response.
|
||||
*/
|
||||
const ERROR_NESTING_PROPERTIES = ['error', 'err', 'response', 'body', 'data'];
|
||||
|
||||
/**
|
||||
* Descriptive messages for common HTTP status codes
|
||||
* this is used by NodeApiError class
|
||||
@@ -187,7 +189,11 @@ export class NodeApiError extends NodeError {
|
||||
this.httpCode = errorResponse.httpCode as string;
|
||||
} else {
|
||||
this.httpCode =
|
||||
this.findProperty(errorResponse, ERROR_STATUS_PROPERTIES, ERROR_NESTING_PROPERTIES) ?? null;
|
||||
this.findProperty(
|
||||
errorResponse,
|
||||
POSSIBLE_ERROR_STATUS_KEYS,
|
||||
POSSIBLE_NESTED_ERROR_OBJECT_KEYS,
|
||||
) ?? null;
|
||||
}
|
||||
|
||||
this.level = level ?? 'warning';
|
||||
@@ -222,8 +228,8 @@ export class NodeApiError extends NodeError {
|
||||
} else {
|
||||
this.description = this.findProperty(
|
||||
errorResponse,
|
||||
ERROR_MESSAGE_PROPERTIES,
|
||||
ERROR_NESTING_PROPERTIES,
|
||||
POSSIBLE_ERROR_MESSAGE_KEYS,
|
||||
POSSIBLE_NESTED_ERROR_OBJECT_KEYS,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -266,8 +272,8 @@ export class NodeApiError extends NodeError {
|
||||
const topLevelKey = Object.keys(result)[0];
|
||||
this.description = this.findProperty(
|
||||
result[topLevelKey],
|
||||
ERROR_MESSAGE_PROPERTIES,
|
||||
['Error'].concat(ERROR_NESTING_PROPERTIES),
|
||||
POSSIBLE_ERROR_MESSAGE_KEYS,
|
||||
POSSIBLE_NESTED_ERROR_OBJECT_KEYS,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user