# How to stop the flow with catch block if any http-request call return a 5xx error?

**URL:** <https://discourse.nodered.org/t/how-to-stop-the-flow-with-catch-block-if-any-http-request-call-return-a-5xx-error/85172>\
**Category:** General\
**Tags:** http-request\
**Created:** [4 February 2024 05:56 UTC](https://discourse.nodered.org/t/how-to-stop-the-flow-with-catch-block-if-any-http-request-call-return-a-5xx-error/85172 "2024-02-04T05:56:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Geheim](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@Geheim](https://discourse.nodered.org/u/Geheim)\
**Post date:** [4 February 2024 05:56 UTC](https://discourse.nodered.org/t/how-to-stop-the-flow-with-catch-block-if-any-http-request-call-return-a-5xx-error/85172/1 "2024-02-04T05:56:29Z")

</div>

I have added a catch block to the flow for http request. I observed that even though the catch block is triggered the flow (within which I have http-request) triggering catch block still continues. This results in the response coming multiple times and node-red throwing an error. My concern is similar to the one asked here (  
[Break flow after http request error](https://discourse.nodered.org/t/break-flow-after-http-request-error/51833)) but the replies on it are a couple of years ago. Is there a way to handle such situations better now?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [4 February 2024 07:10 UTC](https://discourse.nodered.org/t/how-to-stop-the-flow-with-catch-block-if-any-http-request-call-return-a-5xx-error/85172/2 "2024-02-04T07:10:51Z")

</div>

> [@Geheim](#):
>
> Is there a way to handle such situations better now?

I don't think this has changed unfortunately.

I would like to see consistent behaviour for situations like this across all core nodes but as Nick states it would be a behavioural change.

Perhaps one day, in a major version bump we will do a sweep on all the core nodes behaviour but until then, you will need to use a switch after the http request to drop responses. Note: I think if an error is thrown, the `msg` will contain a property named `error` so perhaps that is what you test to ensure only one response is made.

---

<div class="post-metadata">

**Author:** ![Geheim](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@Geheim](https://discourse.nodered.org/u/Geheim)\
**Post date:** [4 February 2024 07:19 UTC](https://discourse.nodered.org/t/how-to-stop-the-flow-with-catch-block-if-any-http-request-call-return-a-5xx-error/85172/3 "2024-02-04T07:19:24Z")

</div>

Actually for errors such as NOT\_FOUND or Server Not Responding I am able to get the flow only to catch by ticking Only send 2xx responses to catch block, is it the right way?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [4 February 2024 07:27 UTC](https://discourse.nodered.org/t/how-to-stop-the-flow-with-catch-block-if-any-http-request-call-return-a-5xx-error/85172/4 "2024-02-04T07:27:31Z")

</div>

I've not used that feature (it was only _recently_ added) so I can't comment on it's behaviour.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 May 2024 07:28 UTC](https://discourse.nodered.org/t/how-to-stop-the-flow-with-catch-block-if-any-http-request-call-return-a-5xx-error/85172/5 "2024-05-04T07:28:07Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
