2019-06-23 03:35:23 -07:00
import { IExecuteFunctions } from 'n8n-core' ;
2022-08-01 13:47:55 -07:00
import { INodeExecutionData , INodeType , INodeTypeDescription } from 'n8n-workflow' ;
2019-06-23 03:35:23 -07:00
export class ErrorTrigger implements INodeType {
description : INodeTypeDescription = {
displayName : 'Error Trigger' ,
name : 'errorTrigger' ,
icon : 'fa:bug' ,
group : [ 'trigger' ] ,
version : 1 ,
description : 'Triggers the workflow when another workflow has an error' ,
:sparkles: Improve Waiting Webhook call state in WF Canvas (#2430)
* N8N-2586 Improve Waiting Webhook call state in WF Canvas
* N8N-2586 Added watcher for showing Webhook's Node Tooltip on execution
* N8N-2586 Show helping tooltip for trigger node if wokrflow is running, it is a trigger node, if it is only one trigger node in WF
* N8N-2586 Rework/Move logic to computed property, Created getter for ActveTriggerNodesInWokrflow, Add style to trigger node's tooltip, remove comments
* N8N-2586 Added EventTriggerDescription prop in INodeTypeDescription Interface, Updated Logic for TriggerNode Tooltip based on the new prop
* N8N-2586 Add new use cases/watcher to show Trigger Nodes Tooltip / If has issues, if paused, if wokrlfow is running, Refactor Getter
* N8N-2586 Added z-index to tooltip, Added new Scenario for Tooltip if it is Draged&Droped on the WF
* N8N-2586 Refactor computed property for draged nodes
* N8N-2586 Fixed Conflicts
* N8N-2586 Fixed Tooltip
* N8N-2586 Dont show tooltip on core trigger nodes that execute automatically
* N8N-2586 Fixed Webhook tooltip when adding/deleting canvas during WF execution
* N8N-2586 Updated Logic, Simplify the code
* N8N-2586 Simplify Code
* N8N-2586 Added check for nodetype
* update dragging to use local state
* N8N-2586 Added eventTriggerDescription to Interval Node
* add comment, use new getter
* update to always check
Co-authored-by: Mutasem <mutdmour@gmail.com>
2021-11-25 14:33:41 -08:00
eventTriggerDescription : '' ,
2022-06-20 12:39:24 -07:00
mockManualExecution : true ,
2019-06-23 03:35:23 -07:00
maxNodes : 1 ,
defaults : {
name : 'Error Trigger' ,
color : '#0000FF' ,
} ,
inputs : [ ] ,
outputs : [ 'main' ] ,
2022-06-20 12:39:24 -07:00
properties : [
{
2022-08-01 13:47:55 -07:00
displayName :
'This node will trigger when there is an error in another workflow, as long as that workflow is set up to do so. <a href="https://docs.n8n.io/integrations/core-nodes/n8n-nodes-base.errortrigger" target="_blank">More info<a>' ,
2022-06-20 12:39:24 -07:00
name : 'notice' ,
type : 'notice' ,
default : '' ,
} ,
] ,
2019-06-23 03:35:23 -07:00
} ;
async execute ( this : IExecuteFunctions ) : Promise < INodeExecutionData [ ] [ ] > {
const items = this . getInputData ( ) ;
const mode = this . getMode ( ) ;
2022-08-01 13:47:55 -07:00
if (
mode === 'manual' &&
items . length === 1 &&
Object . keys ( items [ 0 ] . json ) . length === 0 &&
items [ 0 ] . binary === undefined
) {
2019-06-23 03:35:23 -07:00
// If we are in manual mode and no input data got provided we return
// example data to allow to develope and test errorWorkflows easily
2020-02-19 09:29:03 -08:00
const restApiUrl = this . getRestApiUrl ( ) ;
const urlParts = restApiUrl . split ( '/' ) ;
urlParts . pop ( ) ;
urlParts . push ( 'execution' ) ;
const id = 231 ;
2019-06-23 03:35:23 -07:00
items [ 0 ] . json = {
execution : {
2020-02-19 09:29:03 -08:00
id ,
url : ` ${ urlParts . join ( '/' ) } / ${ id } ` ,
2019-09-11 08:48:14 -07:00
retryOf : '34' ,
2019-06-23 03:35:23 -07:00
error : {
message : 'Example Error Message' ,
2020-10-22 06:46:03 -07:00
stack : 'Stacktrace' ,
2019-06-23 03:35:23 -07:00
} ,
2019-07-17 02:55:26 -07:00
lastNodeExecuted : 'Node With Error' ,
2020-10-22 06:46:03 -07:00
mode : 'manual' ,
2019-06-23 03:35:23 -07:00
} ,
workflow : {
id : '1' ,
2020-10-22 06:46:03 -07:00
name : 'Example Workflow' ,
} ,
2019-06-23 03:35:23 -07:00
} ;
}
return this . prepareOutputData ( items ) ;
}
}