# Detect error in msg.payload

**URL:** <https://discourse.nodered.org/t/detect-error-in-msg-payload/100057>\
**Category:** General\
**Created:** [31 December 2025 14:45 UTC](https://discourse.nodered.org/t/detect-error-in-msg-payload/100057 "2025-12-31T14:45:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![duaw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/duaw/32/20970_2.png) [@duaw](https://discourse.nodered.org/u/duaw)\
**Post date:** [31 December 2025 14:45 UTC](https://discourse.nodered.org/t/detect-error-in-msg-payload/100057/1 "2025-12-31T14:45:55Z")

</div>

Hi!  
My heatpump is occasionally busy. The node (luxtronic) then reports (according to Debug) an `error`

```auto
msg.payload : error
{ name: "Error", message: "heatpump busy - state: 1", stack: "Error: heatpump busy - state: …" }

```

instead of

```auto
msg.payload : Object
{ values: object, parameters: object, additional: object }

```

What is the preferrred way to find out if an error occured. I look now if `payload` has the key `values`. This works, but it feels … kind of indirect.

Cheers, Uwe

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [31 December 2025 15:06 UTC](https://discourse.nodered.org/t/detect-error-in-msg-payload/100057/2 "2025-12-31T15:06:50Z")

</div>

Use a Catch node linked to the luxtronic node and see if that picks it up. If the node is well behaved it should go to the Catch node and not to the normal output.

---

<div class="post-metadata">

**Author:** ![duaw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/duaw/32/20970_2.png) [@duaw](https://discourse.nodered.org/u/duaw)\
**Post date:** [2 January 2026 10:24 UTC](https://discourse.nodered.org/t/detect-error-in-msg-payload/100057/3 "2026-01-02T10:24:23Z")

</div>

A catch node is a good idea, particularly if I wanted to react and do something special in that case.

However, this heat pump error condition is quite "normal". Then I just want to "filter" this out in the normal flow using a `switch`-node.

I thought and asked the best buddy w/ "instance" and the like, but my did tries not work. E.g. JSONATA `$type(payload) = "error"` did not work for me.

But `msg.payload 'has key' values` _correctly_ fails in that 'error' case. So I decided this is a valid condition to continue the flow and stop it otherwise.

But as I said: This is kind of fragile, since it depends on the underlying format (not _that_ fragile, since the Luxtronic node will probably not change its format).

I would like to implement something like

```auto
switch node: 
   if msg.payload is a 'proper' object and not resulting from an 'error'  
       exit 1
   else
      exit 2

```

Cheers, Uwe

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 January 2026 10:38 UTC](https://discourse.nodered.org/t/detect-error-in-msg-payload/100057/4 "2026-01-02T10:38:40Z")

</div>

Does the catch node catch it?

If it does, does that stop it appearing on the normal output?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 January 2026 10:48 UTC](https://discourse.nodered.org/t/detect-error-in-msg-payload/100057/5 "2026-01-02T10:48:03Z")

</div>

You should be able to filter using a switch node, using msg.payload.name != "Error".  
e.g.

```auto
[{"id":"6b9ba61b9e7dcb63","type":"inject","z":"613df62afc8a16bf","name":"error","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":" { \"name\": \"Error\", \"message\": \"heatpump busy \"}","payloadType":"json","x":110,"y":120,"wires":[["068fa6d5ef6c12c0"]]},{"id":"068fa6d5ef6c12c0","type":"switch","z":"613df62afc8a16bf","name":"","property":"payload.name","propertyType":"msg","rules":[{"t":"neq","v":"Error","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":290,"y":140,"wires":[["8630151819cc7629"]]},{"id":"7618f6a801cff71c","type":"inject","z":"613df62afc8a16bf","name":"values","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \"values\":{ \"name\": \"Error\", \"message\": \"heatpump busy \"}}","payloadType":"json","x":110,"y":200,"wires":[["068fa6d5ef6c12c0"]]},{"id":"8630151819cc7629","type":"debug","z":"613df62afc8a16bf","name":"debug 2589","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":450,"y":140,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![duaw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/duaw/32/20970_2.png) [@duaw](https://discourse.nodered.org/u/duaw)\
**Post date:** [2 January 2026 11:23 UTC](https://discourse.nodered.org/t/detect-error-in-msg-payload/100057/6 "2026-01-02T11:23:53Z")

</div>

No, catch does not catch the luxtronic-node error.

---

<div class="post-metadata">

**Author:** ![duaw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/duaw/32/20970_2.png) [@duaw](https://discourse.nodered.org/u/duaw)\
**Post date:** [2 January 2026 11:29 UTC](https://discourse.nodered.org/t/detect-error-in-msg-payload/100057/7 "2026-01-02T11:29:29Z")

</div>

> [@E1cid](#):
>
> msg.payload.name != "Error".

Great! I went for `$exists(payload.name) and payload.name = "Error"` and this does the job.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [2 January 2026 11:44 UTC](https://discourse.nodered.org/t/detect-error-in-msg-payload/100057/8 "2026-01-02T11:44:12Z")

</div>

I don't think JSONata needs to be used here.  
Just msg.payload. name != "Error" in the switch node.  
If payload.name does not exist it would be undefined, therefore !=.

But if it works for you, then what ever you wish to use is OK.

---

<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:** [16 January 2026 11:44 UTC](https://discourse.nodered.org/t/detect-error-in-msg-payload/100057/9 "2026-01-16T11:44:46Z")

</div>

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