{
  "name": "RO-99 Error Handler",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "eac81e25-c10a-4a7e-932c-cbd1e00d9ba6",
      "name": "RO-99.1 Error Trigger"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "2e03787e-194e-4602-9f60-fb37e6bde910",
              "name": "timestamp",
              "value": "={{ $now }}",
              "type": "string"
            },
            {
              "id": "6bd1f9d1-2129-4655-8619-17f61ce36118",
              "name": "workflow",
              "value": "={{ $json.workflow.name }}",
              "type": "string"
            },
            {
              "id": "c5eea3ce-6fef-423d-92ca-13bb4a1c5a54",
              "name": "execution_id",
              "value": "={{ $json.execution.id }}",
              "type": "string"
            },
            {
              "id": "507f6766-7a50-41e5-a3d8-68f86bd6f275",
              "name": "failed_node",
              "value": "={{ $json.lastNodeExecuted }}",
              "type": "string"
            },
            {
              "id": "ea641d68-2847-4e7b-b6c0-a7453a30817f",
              "name": "error_message",
              "value": "={{ $json.error.message }}",
              "type": "string"
            },
            {
              "id": "59020b2e-acdf-433c-9661-9358c77e319b",
              "name": "stack",
              "value": "={{ $json.error.stack }}",
              "type": "string"
            },
            {
              "id": "7e576560-0a5b-4f44-add8-cad95b351eb9",
              "name": "level",
              "value": "ERROR",
              "type": "string"
            },
            {
              "id": "3ce183eb-cf0d-4e83-9702-98c264cd9510",
              "name": "status",
              "value": "OPEN",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        208,
        0
      ],
      "id": "2e02fbba-c5c2-4a27-be84-581bbb1e163f",
      "name": "RO-99.2 Format Error Data"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_WORKFLOW_ERRORS_SPREADSHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "workflow_errors",
          "mode": "name",
          "cachedResultName": "workflow_errors"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "timestamp": "={{ $json.timestamp }}",
            "workflow": "={{ $json.workflow }}",
            "execution_id": "={{ $json.execution_id }}",
            "failed_node": "={{ $json.failed_node }}",
            "error_message": "={{ $json.error_message }}",
            "stack": "={{ $json.stack }}",
            "level": "={{ $json.level }}",
            "status": "={{ $json.status }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "timestamp",
              "displayName": "timestamp",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "workflow",
              "displayName": "workflow",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "execution_id",
              "displayName": "execution_id",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "failed_node",
              "displayName": "failed_node",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "error_message",
              "displayName": "error_message",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "stack",
              "displayName": "stack",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "level",
              "displayName": "level",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "displayName": "status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        416,
        0
      ],
      "id": "f7000c84-f296-4e43-b0ef-d2c7fbe1a04f",
      "name": "RO-99.3 Log Error in Sheets"
    },
    {
      "parameters": {
        "sendTo": "your-email@example.com",
        "subject": "\ud83d\udea8 RiadOps Workflow Error",
        "message": "=Workflow:  {{$json.workflow}}  Execution:  {{$json.execution_id}}  Node:  {{$json.failed_node}}  Error:  {{$json.error_message}}  Time:  {{$json.timestamp}}",
        "options": {}
      },
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.2,
      "position": [
        624,
        0
      ],
      "id": "faf89f6b-01af-412c-825e-d1fea79431a5",
      "name": "RO-99.4 Send Error Alert"
    }
  ],
  "connections": {
    "RO-99.1 Error Trigger": {
      "main": [
        [
          {
            "node": "RO-99.2 Format Error Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RO-99.2 Format Error Data": {
      "main": [
        [
          {
            "node": "RO-99.3 Log Error in Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RO-99.3 Log Error in Sheets": {
      "main": [
        [
          {
            "node": "RO-99.4 Send Error Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "nodeGroups": [],
  "tags": []
}