/** * @node error-trigger * @name Error Trigger * @category triggers * @version 1.0.0 * @description Starts a workflow that another workflow nominated to run when it fails, and passes on what failed * @icon alert-triangle * @trigger */ const configSchema = { type: 'object', properties: {} }; const inputSchema = { type: 'object', properties: { data: { type: 'any', description: 'Failure details supplied when the workflow was triggered' } } }; const outputSchema = { type: 'object', properties: { failedWorkflowId: { type: 'string', description: 'The workflow that failed' }, failedWorkflowName: { type: 'string', description: 'Its name at the time it failed' }, failedExecutionId: { type: 'string', description: 'The execution that failed' }, error: { type: 'string', description: 'The error it reported' }, failedAt: { type: 'number', description: 'When the failure was recorded, in milliseconds' } } }; async function execute(config, input, context) { // Other triggers report that something happened. This one reports what // happened, so the details arrive as its input and are passed straight on. const details = (input && input.data) || input || {}; const failedWorkflowName = details.failedWorkflowName || ''; smartbotic.log.info('Error trigger: handling failure of ' + (failedWorkflowName || 'an unknown workflow')); return { failedWorkflowId: details.failedWorkflowId || '', failedWorkflowName: failedWorkflowName, failedExecutionId: details.failedExecutionId || '', error: details.error || '', failedAt: details.failedAt || Date.now() }; } module.exports = { configSchema, inputSchema, outputSchema, execute };