# Function nodes and throw

**URL:** <https://discourse.nodered.org/t/function-nodes-and-throw/14755>\
**Category:** General\
**Created:** [25 August 2019 02:15 UTC](https://discourse.nodered.org/t/function-nodes-and-throw/14755 "2019-08-25T02:15:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thatcadguy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thatcadguy/32/5273_2.png) [@thatcadguy](https://discourse.nodered.org/u/thatcadguy)\
**Post date:** [25 August 2019 02:15 UTC](https://discourse.nodered.org/t/function-nodes-and-throw/14755/1 "2019-08-25T02:15:24Z")

</div>

I was writing a function node and when I went to test, noticed something peculiar: when throwing an error, instead of showing the throw's message, I get:

```auto
TypeError: Cannot read property 'search' of undefined

```

You can reproduce this by simply putting a throw statement into a function node. Is the use of throw not supported?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [25 August 2019 04:20 UTC](https://discourse.nodered.org/t/function-nodes-and-throw/14755/2 "2019-08-25T04:20:39Z")

</div>

There was a [issue created recently](https://github.com/node-red/node-red/issues/2269).

---

<div class="post-metadata">

**Author:** ![thatcadguy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thatcadguy/32/5273_2.png) [@thatcadguy](https://discourse.nodered.org/u/thatcadguy)\
**Post date:** [25 August 2019 04:27 UTC](https://discourse.nodered.org/t/function-nodes-and-throw/14755/3 "2019-08-25T04:27:15Z")

</div>

Right-o, thanks @bakman2 !

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [25 August 2019 07:07 UTC](https://discourse.nodered.org/t/function-nodes-and-throw/14755/4 "2019-08-25T07:07:35Z")

</div>

Yes , until that fix, you need to throw a real error not a string.

> <https://stackoverflow.com/questions/11502052/throwing-strings-instead-of-errors/27501348#27501348>
