# Advanced flow, how to return an error?

**URL:** <https://community.homey.app/t/advanced-flow-how-to-return-an-error/75455>\
**Category:** Questions & Help\
**Tags:** advancedflow\
**Created:** [January 22, 2023, 7:52pm UTC](https://community.homey.app/t/advanced-flow-how-to-return-an-error/75455 "2023-01-22T19:52:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![B3rt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/b3rt/32/9435_2.png) [@B3rt](https://community.homey.app/u/B3rt)\
**Post date:** [January 22, 2023, 7:52pm UTC](https://community.homey.app/t/advanced-flow-how-to-return-an-error/75455/1 "2023-01-22T19:52:03Z")

</div>

I use the advanced flow cards and i do a http request to a (php) script on an server, sometimes i need to stop the flow card if something goes wrong in the script so i wish to return an error.

What do i exactly return in the script to error the advanced http get flow card?  
I tried:  
http\_response\_code(400); // also tried several error codes  
$return[‘result’] = ‘false’;  
$return[‘msg’] = ‘error kon commando niet uitvoeren’;  
echo json\_encode($return);

But this does not work, the advanced card stil continues ‘normally’…

---

<div class="post-metadata">

**Author:** ![spkesDE](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/spkesde/32/54352_2.png) [@spkesDE](https://community.homey.app/u/spkesDE)\
**Post date:** [January 22, 2023, 7:54pm UTC](https://community.homey.app/t/advanced-flow-how-to-return-an-error/75455/2 "2023-01-22T19:54:57Z")

</div>

I think you’re using Homey Script?

Try to throw an error

```auto
throw new Error("My Error");

```

---

<div class="post-metadata">

**Author:** ![B3rt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/b3rt/32/9435_2.png) [@B3rt](https://community.homey.app/u/B3rt)\
**Post date:** [January 22, 2023, 8:14pm UTC](https://community.homey.app/t/advanced-flow-how-to-return-an-error/75455/3 "2023-01-22T20:14:09Z")

</div>

I do have homeyscript installed but not using it, this what i do:  
 ![2023-01-22_211121](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/e/1e71949ffbedef780ab07225358d3fa89c833c46.png)

The card it self works, it calls the url and the script is executed, but sometimes i need to send a error back so the ‘red’ line is triggered because there was an error.

---

<div class="post-metadata">

**Author:** ![spkesDE](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/spkesde/32/54352_2.png) [@spkesDE](https://community.homey.app/u/spkesDE)\
**Post date:** [January 22, 2023, 8:27pm UTC](https://community.homey.app/t/advanced-flow-how-to-return-an-error/75455/4 "2023-01-22T20:27:22Z")

</div>

> [@B3rt](#):
>
> The card it self works, it calls the url and the script is executed, but sometimes i need to send a error back so the ‘red’ line is triggered because there was an error.

That will not work. It would throw an error if the http request fails (Timeout, 404 etc)
