From 0fd8d0e2bfce5407da3b8645f42b281e1bfeffde Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 4 Jul 2017 20:12:53 +0100 Subject: [PATCH] Make send-error behaviour optional in file node Existing nodes will have sendError enabled. New instances will default to it being disabled. --- nodes/core/locales/en-US/messages.json | 1 + nodes/core/storage/50-file.html | 26 ++++++++++++++++++++++++-- nodes/core/storage/50-file.js | 15 +++++++++++---- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/nodes/core/locales/en-US/messages.json b/nodes/core/locales/en-US/messages.json index 1691b7644..91a4fdae8 100644 --- a/nodes/core/locales/en-US/messages.json +++ b/nodes/core/locales/en-US/messages.json @@ -762,6 +762,7 @@ "breakchunks": "Break into chunks", "breaklines": "Break into lines", "filelabel": "file", + "sendError": "Send message on error (legacy mode)", "deletelabel": "delete __file__" }, "action": { diff --git a/nodes/core/storage/50-file.html b/nodes/core/storage/50-file.html index 5811d035a..cd17b0820 100644 --- a/nodes/core/storage/50-file.html +++ b/nodes/core/storage/50-file.html @@ -40,7 +40,7 @@

Details

Each message payload will be added to the end of the file, optionally appending a newline (\n) character between each one.

-

If msg.filename is used the file will be closed after every write. +

If msg.filename is used the file will be closed after every write. For best performance use a fixed filename.

It can be configured to overwrite the entire file rather than append. For example, when writing binary data to a file, such as an image, this option should be used @@ -62,6 +62,11 @@ +

+ + + +
@@ -82,6 +87,12 @@
The contents of the file as either a string or binary buffer.
filename string
If not configured in the node, this optional property sets the name of the file to be read.
+
error object
+
deprecated: If enabled in the node, when the node hits an error + reading the file, it will send a message with no payload + and this error property set to the error details. This + mode of behaviour is deprecated and not enabled by default for new + instances of the node. See below for more information.

Details

The filename should be an absolute path, otherwise it will be relative to @@ -89,6 +100,13 @@

On Windows, path separators may need to be escaped, for example: \\Users\\myUser.

Optionally, a text file can be split into lines, outputting one message per line, or a binary file file into smaller buffer chunks, the chunk size is operating system dependant, but typically 64k (linux/mac) or 41k (Windows).

+

Legacy error handling

+

Before Node-RED 0.17, if this node hit an error whilst reading the file, it would + send a message with no msg.payload and msg.error set to the + details of the error. This is a deprecated mode of behaviour for the node that new + instances will not do. If required, this mode can be re-enabled within the node + configuration.

+

Errors should be caught and handled using a Catch node.