code: function sendError(node, msg, err, ...attrs) {
          if (check.string(err)) {
              msg.error = {
                  node: node.name,
                  message: util.format(err, ...attrs),
              };
          } else if (check.instance(err, Error)) {
              msg.error = err;
          }
          node.error(node.name + ': ' + msg.error.message, msg);
      }
docs: sends Error back to node-red
  @function
  @param {object} node - the node object returned by createNode
  @param {object} msg - msg object passed as input to this node.
  @param {object} err - error object.
  @param {object} attrs - attrs to be used to construct error message.