# How to Catch "msg : error"?

**URL:** <https://discourse.nodered.org/t/how-to-catch-msg-error/51657>\
**Category:** General\
**Created:** [29 September 2021 07:50 UTC](https://discourse.nodered.org/t/how-to-catch-msg-error/51657 "2021-09-29T07:50:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lueftermann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lueftermann/32/48385_2.png) [@Lueftermann](https://discourse.nodered.org/u/Lueftermann)\
**Post date:** [29 September 2021 07:50 UTC](https://discourse.nodered.org/t/how-to-catch-msg-error/51657/1 "2021-09-29T07:50:31Z")

</div>

Hello,  
I have establish communication between my PLC (Eaton E4) and an OPCUA Server. I think everything works fine. But in case of losing conncection to my PLC my console gives me "msg : error", I tried to catch it with catch node - but it does not work. I am new to Node-Red and I don't have an idea what to do now.

I hope you can help me. Thank you 🙂

Here is a minimal example:

```auto
[
    {
        "id": "8ed0d7b629d5bc0e",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "90515af6a98ac6d9",
        "type": "easyE4 COM",
        "z": "8ed0d7b629d5bc0e",
        "name": "Easy_1",
        "deviceId": "123",
        "ip": "192.168.1.117",
        "baseAuthPass": "peter",
        "authScheme": "Basic",
        "protocol": "http",
        "baseAuthUser": "peter",
        "cycleTime": "500",
        "x": 440,
        "y": 160,
        "wires": [
            [
                "f1f9d46a6fd3329f"
            ]
        ]
    },
    {
        "id": "77100a53f2650f29",
        "type": "easyE4 IN",
        "z": "8ed0d7b629d5bc0e",
        "name": "",
        "deviceId": "123",
        "selectOpList": [
            {
                "type": "0",
                "index": "1,8"
            },
            {
                "type": "7",
                "index": "104"
            },
            {
                "type": "1",
                "index": "1,8"
            },
            {
                "type": "8",
                "index": "100"
            },
            {
                "type": "8",
                "index": "102"
            },
            {
                "type": "5",
                "index": "17,32"
            }
        ],
        "sysinfo": [
            "All"
        ],
        "fb": "",
        "indexRange": "",
        "x": 430,
        "y": 220,
        "wires": [
            [
                "56b90cd73e613f91"
            ]
        ]
    },
    {
        "id": "e7ada31a502a8f96",
        "type": "catch",
        "z": "8ed0d7b629d5bc0e",
        "name": "",
        "scope": [
            "77100a53f2650f29"
        ],
        "uncaught": false,
        "x": 190,
        "y": 280,
        "wires": [
            [
                "f1fef18d2c301a2d",
                "06da0c62815f7c8a"
            ]
        ]
    },
    {
        "id": "56b90cd73e613f91",
        "type": "debug",
        "z": "8ed0d7b629d5bc0e",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 650,
        "y": 220,
        "wires": []
    },
    {
        "id": "662320bb37425612",
        "type": "inject",
        "z": "8ed0d7b629d5bc0e",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payloadType": "date",
        "x": 210,
        "y": 160,
        "wires": [
            [
                "90515af6a98ac6d9"
            ]
        ]
    },
    {
        "id": "f1f9d46a6fd3329f",
        "type": "debug",
        "z": "8ed0d7b629d5bc0e",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 650,
        "y": 160,
        "wires": []
    },
    {
        "id": "f1fef18d2c301a2d",
        "type": "debug",
        "z": "8ed0d7b629d5bc0e",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "error.message",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 670,
        "y": 280,
        "wires": []
    },
    {
        "id": "06da0c62815f7c8a",
        "type": "template",
        "z": "8ed0d7b629d5bc0e",
        "name": "",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "No conncection to device!",
        "output": "str",
        "x": 440,
        "y": 340,
        "wires": [
            [
                "417c378bc99783f2"
            ]
        ]
    },
    {
        "id": "417c378bc99783f2",
        "type": "debug",
        "z": "8ed0d7b629d5bc0e",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 650,
        "y": 340,
        "wires": []
    }
]

```

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [29 September 2021 08:38 UTC](https://discourse.nodered.org/t/how-to-catch-msg-error/51657/2 "2021-09-29T08:38:52Z")

</div>

Hi,  
Give it a try with the **status** node, maybe it will show the connection status.  
Hard to try here if you don't have the plc.

---

<div class="post-metadata">

**Author:** ![Lueftermann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lueftermann/32/48385_2.png) [@Lueftermann](https://discourse.nodered.org/u/Lueftermann)\
**Post date:** [29 September 2021 09:02 UTC](https://discourse.nodered.org/t/how-to-catch-msg-error/51657/3 "2021-09-29T09:02:49Z")

</div>

I tried that too, with msg.status.text but I don't get an output..

> [@edje11](#):
>
> Hard to try here if you don't have the plc.

Hmm.. I think not, because the error is for no connection to plc, so it would work without it.. 😃

Thank you for the answer. 🙂

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [29 September 2021 11:16 UTC](https://discourse.nodered.org/t/how-to-catch-msg-error/51657/4 "2021-09-29T11:16:45Z")

</div>

The **easyE4 COM:** node is always saying that's connected. Even if I don't have the plc and the used ipaddress is not existing.  
Looks a bug to me in this node and you have to contact the author.

 ![Capture](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/b/8bc9079d86edad0c5bbf9825b0575e52846c8fc7.png)

---

<div class="post-metadata">

**Author:** ![Lueftermann](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lueftermann/32/48385_2.png) [@Lueftermann](https://discourse.nodered.org/u/Lueftermann)\
**Post date:** [30 September 2021 06:26 UTC](https://discourse.nodered.org/t/how-to-catch-msg-error/51657/5 "2021-09-30T06:26:45Z")

</div>

Yeah I noticed that too and did that already. The easyE4 IN node works and shows the correct connection state.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [29 November 2021 06:27 UTC](https://discourse.nodered.org/t/how-to-catch-msg-error/51657/6 "2021-11-29T06:27:28Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
