Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Always retain original errors in the error chain on NodeOperationError #4951

Merged
merged 1 commit into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/nodes-base/nodes/FileMaker/FileMaker.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ export class FileMaker implements INodeType {
try {
returnData = await layoutsApiRequest.call(this);
} catch (error) {
throw new NodeOperationError(this.getNode(), `FileMaker Error: ${error}`);
throw new NodeOperationError(this.getNode(), error);
}

return returnData;
Expand All @@ -620,7 +620,7 @@ export class FileMaker implements INodeType {
try {
layouts = await layoutsApiRequest.call(this);
} catch (error) {
throw new NodeOperationError(this.getNode(), `FileMaker Error: ${error}`);
throw new NodeOperationError(this.getNode(), error);
}
for (const layout of layouts) {
returnData.push({
Expand All @@ -638,7 +638,7 @@ export class FileMaker implements INodeType {
try {
fields = await getFields.call(this);
} catch (error) {
throw new NodeOperationError(this.getNode(), `FileMaker Error: ${error}`);
throw new NodeOperationError(this.getNode(), error);
}
for (const field of fields) {
returnData.push({
Expand All @@ -656,7 +656,7 @@ export class FileMaker implements INodeType {
try {
scripts = await getScripts.call(this);
} catch (error) {
throw new NodeOperationError(this.getNode(), `FileMaker Error: ${error}`);
throw new NodeOperationError(this.getNode(), error);
}
for (const script of scripts) {
if (!script.isFolder) {
Expand All @@ -676,7 +676,7 @@ export class FileMaker implements INodeType {
try {
portals = await getPortals.call(this);
} catch (error) {
throw new NodeOperationError(this.getNode(), `FileMaker Error: ${error}`);
throw new NodeOperationError(this.getNode(), error);
}
Object.keys(portals).forEach((portal) => {
returnData.push({
Expand All @@ -700,7 +700,7 @@ export class FileMaker implements INodeType {
try {
token = await getToken.call(this);
} catch (error) {
throw new NodeOperationError(this.getNode(), `Login fail: ${error}`);
throw new NodeOperationError(this.getNode(), new Error('Login fail', { cause: error }));
}

let requestOptions: OptionsWithUri;
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/Jira/JiraTrigger.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ export class JiraTrigger implements INodeType {
} catch (e) {
throw new NodeOperationError(
this.getNode(),
`Could not retrieve HTTP Query Auth credentials: ${e}`,
new Error('Could not retrieve HTTP Query Auth credentials', { cause: e }),
);
}
if (!httpQueryAuth.name && !httpQueryAuth.value) {
Expand Down
4 changes: 3 additions & 1 deletion packages/nodes-base/nodes/N8n/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ export const parseAndSetBodyJson = (
} catch (err) {
throw new NodeOperationError(
this.getNode(),
`The '${parameterName}' property must be valid JSON, but cannot be parsed: ${err}`,
new Error(`The '${parameterName}' property must be valid JSON, but cannot be parsed`, {
cause: err,
}),
);
}
return requestOptions;
Expand Down
10 changes: 8 additions & 2 deletions packages/nodes-base/nodes/NocoDB/NocoDB.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ export class NocoDB implements INodeType {
const responseData = await apiRequest.call(this, requestMethod, endpoint, {}, {});
return responseData.list.map((i: IDataObject) => ({ name: i.title, value: i.id }));
} catch (e) {
throw new NodeOperationError(this.getNode(), `Error while fetching projects! (${e})`);
throw new NodeOperationError(
this.getNode(),
new Error('Error while fetching projects!', { cause: e }),
);
}
},
// This only supports using the Project ID
Expand All @@ -193,7 +196,10 @@ export class NocoDB implements INodeType {
const responseData = await apiRequest.call(this, requestMethod, endpoint, {}, {});
return responseData.list.map((i: IDataObject) => ({ name: i.title, value: i.id }));
} catch (e) {
throw new NodeOperationError(this.getNode(), `Error while fetching tables! (${e})`);
throw new NodeOperationError(
this.getNode(),
new Error('Error while fetching tables!', { cause: e }),
);
}
} else {
throw new NodeOperationError(this.getNode(), `No project selected!`);
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export namespace SendInBlueNode {

return requestOptions;
} catch (err) {
throw new NodeOperationError(this.getNode(), `${err}`);
throw new NodeOperationError(this.getNode(), err);
}
}

Expand Down