Skip to content

Commit 05dfeec

Browse files
committed
Remove error handling flow dev section
1 parent f9d10d5 commit 05dfeec

File tree

5 files changed

+62
-27
lines changed

5 files changed

+62
-27
lines changed

_includes/toc-developing-flows.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<li class="toctitle active"><a href="/docs/developing-flows/">Developing Flows</a></li>
66
<li {% if page.url == "/docs/developing-flows/flow-structure" %}class="active"{% endif %}><a href="/docs/developing-flows/flow-structure">Flow structure</a></li>
77
<li {% if page.url == "/docs/developing-flows/message-design" %}class="active"{% endif %}><a href="/docs/developing-flows/message-design">Message design</a></li>
8-
<li {% if page.url == "/docs/developing-flows/error-handling" %}class="active"{% endif %}><a href="/docs/developing-flows/error-handling">Error handling</a></li>
98
<li {% if page.url == "/docs/developing-flows/documenting-flows" %}class="active"{% endif %}><a href="/docs/developing-flows/documenting-flows">Documenting Flows</a></li>
109
</ul>
1110
<hr>

docs/developing-flows/error-handling.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

docs/developing-flows/flow-structure.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,18 @@ The same approach can be used when the flows might run on different operating sy
9898

9999
The Inject and Change nodes are able to access environment variables using either the "env" option in their TypedInput. The Function node can use the `env.get()` function.
100100

101+
### Error handling
102+
103+
Node-RED provides the Catch and Status nodes as ways of building flows that can respond to errors. For more information about how they can be used, refer to the [user guide](/docs/user-guide/handling-errors).
104+
105+
As there is no direct visual association between a Catch node and the nodes it targets, you should consider how to position them in order to keep the flows readable.
106+
107+
Placing them close to the parts of the flow they correspond to can help, but you should take care not cause your flows to be come overcrowded.
108+
109+
Although approach is to group all of the error handling flows below the main flow - making the 'good' path clearly distinct from the error paths.
110+
111+
Giving your Catch nodes a clear name is also very important to help easily identify the scenarios they are intended to handle.
112+
113+
Which ever approach you choose, try to be consistent across your different flows.
114+
115+

docs/developing-flows/index.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,6 @@ into smaller, reusable components and how to customise them for different platfo
3939

4040
[more...](message-design)
4141

42-
### [Error handling](error-handling)
43-
44-
**Not written yet**
45-
46-
- How to handle errors in flows
47-
- what can or cannot be caught be a Catch node
48-
- Where Status node can be used
49-
- Layout of Catch/Status nodes in relation to what they target
50-
- Avoiding loops
51-
52-
[more...](error-handling)
53-
5442
### [Documenting flows](documenting-flows)
5543

5644
All good code should have good documentation to match. This section looks at what

docs/user-guide/handling-errors.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ title: Handling errors
55
slug: handling-errors
66
---
77

8+
Whilst it is easy to create flows that do the right thing when everything works,
9+
it is also important to think about what could go wrong.
10+
11+
For example, if the flow interacts with an external database or API, what happens
12+
if it stops responding to requests? Or what if the MQTT nodes lose their connection
13+
to a broker?
14+
15+
Error handling in any application is essential to ensure these sorts of events
16+
are handled properly. What it means to handle the error will depend on the
17+
requirements of the application. You may want to try an action that failed, or
18+
trigger a separate alert, or maybe the error is an entirely expected event that
19+
is just another part of the application logic.
820

921
Node-RED provides two ways for a node to report an error. It can either just
1022
write a message to the log or it can notify the runtime of the error and cause
@@ -22,7 +34,8 @@ There is a third sort of error that can cause the Node-RED runtime to shutdown.
2234
in nodes.
2335

2436
This guide describes each of these error types in more detail and shows what can
25-
be done to handle them.
37+
be done to handle them. It also looks at how the Status events of a node can be
38+
used to create flows that [handle unexpected events](#handling-status-changes).
2639

2740

2841
### Logging errors
@@ -102,6 +115,13 @@ This allows you to create error handling flows that target specific nodes and al
102115
have an error handler that will catch "everything else".
103116

104117

118+
#### Errors in subflows
119+
120+
If an error is logged from inside a subflow, the runtime will first check for any
121+
Catch nodes inside the subflow. If there are none there, the error will propagate
122+
up to the flow containing the subflow instance.
123+
124+
105125
### Uncatchable errors
106126

107127
These are the errors a node writes to the log without notifying the runtime properly.
@@ -136,3 +156,29 @@ caused the error and raise an issue against it. This is not always easy due to t
136156
The stack trace provided in the Node-RED log will provide some clues as to the
137157
nature of the asynchronous task that hit the error, which in turn may help you
138158
to identify the node at fault.
159+
160+
### Handling Status Changes
161+
162+
Not all errors conditions will appear as error events that can be caught be a
163+
Catch node. For example, the MQTT nodes losing their connection will not trigger
164+
an error, but they will trigger a change of their status.
165+
166+
Just as the Catch node can be used to handle error events, the Status node can
167+
be used to handle changes in a node's status.
168+
169+
The message sent by the Status node includes the `status` property that gives
170+
information about the status and the node that triggered the event.
171+
172+
```json
173+
{
174+
"status": {
175+
"fill": "red",
176+
"shape": "ring",
177+
"text": "node-red:common.status.disconnected",
178+
"source": {
179+
"id": "27bbb5b1.d3eb3a",
180+
"type": "mqtt out"
181+
}
182+
}
183+
}
184+
```

0 commit comments

Comments
 (0)