mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #3167 from node-red/httprequest-send-error
Add option to only send http response errors to Catch node
This commit is contained in:
commit
2a0b4ea828
@ -86,6 +86,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<input type="checkbox" id="node-input-senderr" style="display: inline-block; width: auto; vertical-align: top;">
|
||||
<label for="node-input-senderr" style="width: auto" data-i18n="httpin.senderr"></label>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-ret"><i class="fa fa-arrow-left"></i> <span data-i18n="httpin.label.return"></span></label>
|
||||
<select type="text" id="node-input-ret" style="width:70%;">
|
||||
@ -114,7 +120,8 @@
|
||||
tls: {type:"tls-config",required: false},
|
||||
persist: {value:false},
|
||||
proxy: {type:"http proxy",required: false},
|
||||
authType: {value: ""}
|
||||
authType: {value: ""},
|
||||
senderr: {value: false}
|
||||
},
|
||||
credentials: {
|
||||
user: {type:"text"},
|
||||
|
@ -72,6 +72,7 @@ in your Node-RED user directory (${RED.settings.userDir}).
|
||||
var paytoqs = false;
|
||||
var paytobody = false;
|
||||
var redirectList = [];
|
||||
var sendErrorsToCatch = n.senderr;
|
||||
|
||||
var nodeHTTPPersistent = n["persist"];
|
||||
if (n.tls) {
|
||||
@ -537,10 +538,16 @@ in your Node-RED user directory (${RED.settings.userDir}).
|
||||
nodeSend(msg);
|
||||
nodeDone();
|
||||
}).catch(err => {
|
||||
if(err.code === 'ETIMEDOUT' || err.code === 'ESOCKETTIMEDOUT') {
|
||||
// Pre 2.1, any errors would be sent to both Catch node and sent on as normal.
|
||||
// This is not ideal but is the legacy behaviour of the node.
|
||||
// 2.1 adds the 'senderr' option, if set to true, will *only* send errors
|
||||
// to Catch nodes. If false, it still does both behaviours.
|
||||
// TODO: 3.0 - make it one or the other.
|
||||
|
||||
if (err.code === 'ETIMEDOUT' || err.code === 'ESOCKETTIMEDOUT') {
|
||||
node.error(RED._("common.notification.errors.no-response"), msg);
|
||||
node.status({fill:"red", shape:"ring", text:"common.notification.errors.no-response"});
|
||||
}else{
|
||||
} else {
|
||||
node.error(err,msg);
|
||||
node.status({fill:"red", shape:"ring", text:err.code});
|
||||
}
|
||||
@ -549,7 +556,9 @@ in your Node-RED user directory (${RED.settings.userDir}).
|
||||
if (node.metric() && timingLog) {
|
||||
emitTimingMetricLog(err.timings, msg);
|
||||
}
|
||||
nodeSend(msg);
|
||||
if (!sendErrorsToCatch) {
|
||||
nodeSend(msg);
|
||||
}
|
||||
nodeDone();
|
||||
});
|
||||
});
|
||||
|
@ -486,6 +486,7 @@
|
||||
"proxy-config": "Proxy Configuration",
|
||||
"use-proxyauth": "Use proxy authentication",
|
||||
"noproxy-hosts": "Ignore hosts",
|
||||
"senderr": "Only send non-2xx responses to Catch node",
|
||||
"utf8": "a UTF-8 string",
|
||||
"binary": "a binary buffer",
|
||||
"json": "a parsed JSON object",
|
||||
|
Loading…
Reference in New Issue
Block a user