I just started learning node-red and i am trying to handle exception of HTTP request node.
When ECONNREFUSED error occurs i try to catch it with CATCH Node.
Error is catched with CATCH but also next node after HTTP Request is executed.
What i am doing wrong? Is this normal behavior?
Thanks
Hi,
What about using a Switch node after your Http request to handle the direction you want your application to take in case of failure.
Example Flow : (using jsonplaceholder that is a fake API for testing and prototyping)
[{"id":"aeca6a39.21847","type":"inject","z":"94ab22aa.035ba","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":1480,"wires":[["9d03c4de.3463c"]]},{"id":"9d03c4de.3463c","type":"http request","z":"94ab22aa.035ba","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://jsonplaceholder.typicode.com/users","tls":"","persist":false,"proxy":"","authType":"","x":450,"y":1480,"wires":[["82442f8.50d63d"]]},{"id":"5e5e9f20.b2517","type":"inject","z":"94ab22aa.035ba","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":1600,"wires":[["b492fa76.ade698"]]},{"id":"b492fa76.ade698","type":"http request","z":"94ab22aa.035ba","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://jsonplaceholder.typicode.com/usersxxxx","tls":"","persist":false,"proxy":"","authType":"","x":450,"y":1600,"wires":[["db0c209f.0091b8"]]},{"id":"c40262b6.ef6d98","type":"debug","z":"94ab22aa.035ba","name":"FAIL","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":800,"y":1580,"wires":[]},{"id":"db0c209f.0091b8","type":"switch","z":"94ab22aa.035ba","name":"","property":"statusCode","propertyType":"msg","rules":[{"t":"neq","v":"200","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":1600,"wires":[["c40262b6.ef6d98"],["2f9d5c6c.9b9e74"]]},{"id":"2f9d5c6c.9b9e74","type":"debug","z":"94ab22aa.035ba","name":"OK","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":800,"y":1620,"wires":[]},{"id":"3b570afe.df2b06","type":"debug","z":"94ab22aa.035ba","name":"FAIL","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":800,"y":1460,"wires":[]},{"id":"82442f8.50d63d","type":"switch","z":"94ab22aa.035ba","name":"","property":"statusCode","propertyType":"msg","rules":[{"t":"neq","v":"200","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":1480,"wires":[["3b570afe.df2b06"],["4b7010de.08bf3"]]},{"id":"4b7010de.08bf3","type":"debug","z":"94ab22aa.035ba","name":"OK","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":800,"y":1500,"wires":[]},{"id":"f33e25d0.55c948","type":"comment","z":"94ab22aa.035ba","name":"URL Exists","info":"","x":440,"y":1440,"wires":[]},{"id":"b93991d0.38cc2","type":"comment","z":"94ab22aa.035ba","name":"URL doesnt Exist","info":"","x":460,"y":1560,"wires":[]}]
Sounds good. Appreciate your help
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.