🚚 Directorize and alphabetize nodes (#2445)

* 🚚 Directorize nodes

*  Alphabetize nodes and credentials

* 🔥 Remove unused node

* 🔥 Remove unused codex

* 🔥 Remove duplicate cred file references

* 🐛 Fix node file paths

* 🔥 Remove duplicate node reference
This commit is contained in:
Iván Ovejero
2021-11-17 17:30:14 +01:00
committed by GitHub
parent 0022c7eb09
commit 766f74c782
95 changed files with 109 additions and 472 deletions

View File

@@ -0,0 +1,26 @@
{
"node": "n8n-nodes-base.stopAndError",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": [
"Core Nodes",
"Utility"
],
"resources": {
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/nodes/n8n-nodes-base.stopAndError/"
}
]
},
"alias": [
"Throw error",
"Error",
"Exception"
],
"subcategories": {
"Core Nodes":[
"Helpers"
]
}
}

View File

@@ -0,0 +1,110 @@
import {
IExecuteFunctions,
} from 'n8n-core';
import {
INodeExecutionData,
INodeType,
INodeTypeDescription,
NodeOperationError,
} from 'n8n-workflow';
const errorObjectPlaceholder = `{
"code": "404",
"description": "The resource could not be fetched"
}`;
export class StopAndError implements INodeType {
description: INodeTypeDescription = {
displayName: 'Stop and Error',
name: 'stopAndError',
icon: 'fa:exclamation-triangle',
group: ['input'],
version: 1,
description: 'Throw an error in the workflow',
defaults: {
name: 'Stop And Error',
color: '#ff0000',
},
inputs: ['main'],
outputs: [],
properties: [
{
displayName: 'Error Type',
name: 'errorType',
type: 'options',
options: [
{
name: 'Error Message',
value: 'errorMessage',
},
{
name: 'Error Object',
value: 'errorObject',
},
],
default: 'errorMessage',
description: 'Type of error to throw',
},
{
displayName: 'Error Message',
name: 'errorMessage',
type: 'string',
placeholder: 'An error occurred!',
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
required: true,
displayOptions: {
show: {
errorType: [
'errorMessage',
],
},
},
},
{
displayName: 'Error Object',
name: 'errorObject',
type: 'json',
description: 'Object containing error properties',
default: '',
typeOptions: {
alwaysOpenEditWindow: true,
},
placeholder: errorObjectPlaceholder,
required: true,
displayOptions: {
show: {
errorType: [
'errorObject',
],
},
},
},
],
};
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const errorType = this.getNodeParameter('errorType', 0) as 'errorMessage' | 'errorObject';
const { id: workflowId, name: workflowName } = this.getWorkflow();
let toThrow: string | { name: string; message: string; [otherKey: string]: unknown };
if (errorType === 'errorMessage') {
toThrow = this.getNodeParameter('errorMessage', 0) as string;
} else {
const json = this.getNodeParameter('errorObject', 0) as string;
const errorObject = JSON.parse(json);
toThrow = {
name: 'User-thrown error',
message: `Workflow ID ${workflowId} "${workflowName}" has failed`,
...errorObject,
};
}
throw new NodeOperationError(this.getNode(), toThrow);
}
}