Skip to content

How to handle / catch errors? #35

@jerkstorecaller

Description

@jerkstorecaller

My scenario is this: I'd like to use bigssh to run a remote command that might print warnings to stderr, even for invocations that run fine (exit code 0). I also need to handle actual errors (exit code not 0) to detect real failures.

I'm not sure how I'm supposed to do this, without doing something fragile like text parsing stderr looking for the word "Return code" since that's bigssh's error message. The 3rd output doesn't give an exit code. And the error, despite stopping the flow, doesn't appear to be handlable in a Catch node.

Any advice?

Here's an example flow:

[
    {
        "id": "f9409b6cb34e08bc",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "368b47d307b01b06",
        "type": "bigssh",
        "z": "f9409b6cb34e08bc",
        "name": "query-remote-system",
        "commandLine": "badcmd",
        "commandArgs": "",
        "minError": 1,
        "minWarning": 1,
        "noStdin": false,
        "format": "utf8",
        "payloadIsArg": false,
        "myssh": "76f22fcf7a69e187",
        "x": 360,
        "y": 120,
        "wires": [
            [
                "673491caacc9f7f7"
            ],
            [],
            []
        ]
    },
    {
        "id": "3707e406739b9d18",
        "type": "inject",
        "z": "f9409b6cb34e08bc",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payloadType": "date",
        "x": 140,
        "y": 120,
        "wires": [
            [
                "368b47d307b01b06"
            ]
        ]
    },
    {
        "id": "e531dce5ce945878",
        "type": "catch",
        "z": "f9409b6cb34e08bc",
        "name": "handle-errors",
        "scope": null,
        "uncaught": false,
        "x": 250,
        "y": 300,
        "wires": [
            [
                "1c540326e5abcc56"
            ]
        ]
    },
    {
        "id": "1c540326e5abcc56",
        "type": "debug",
        "z": "f9409b6cb34e08bc",
        "name": "all-bad",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 420,
        "y": 300,
        "wires": []
    },
    {
        "id": "673491caacc9f7f7",
        "type": "debug",
        "z": "f9409b6cb34e08bc",
        "name": "all-good",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 600,
        "y": 120,
        "wires": []
    },
    {
        "id": "76f22fcf7a69e187",
        "type": "SSH_Credentials",
        "host": "10.2.0.13",
        "port": "22",
        "userlabel": "user@10.2.0.13"
    }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions