Returning Error from within C++ addon?

72 views
Skip to first unread message

Ryan Cole

unread,
Nov 10, 2012, 3:19:14 PM11/10/12
to nod...@googlegroups.com
I'm writing an addon in C++ and would like to pass an Error to a callback function if an error occurs. I see how to throw exceptions, but in this case I simply want to pass an Error. I've looked through v8 docs and node.h but don't see any examples of returning an Error. I know this must be extremely simple but I'm just not seeing how to do it.

Thanks.

Fedor Indutny

unread,
Nov 10, 2012, 3:52:56 PM11/10/12
to nod...@googlegroups.com
Use Exception::Error(String::New("Error message")) to create error object.

Cheers,
Fedor.



On Sun, Nov 11, 2012 at 12:19 AM, Ryan Cole <ry...@rycole.com> wrote:
I'm writing an addon in C++ and would like to pass an Error to a callback function if an error occurs. I see how to throw exceptions, but in this case I simply want to pass an Error. I've looked through v8 docs and node.h but don't see any examples of returning an Error. I know this must be extremely simple but I'm just not seeing how to do it.

Thanks.

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Ryan Cole

unread,
Nov 10, 2012, 7:00:08 PM11/10/12
to nod...@googlegroups.com, fe...@indutny.com
Awesome, thanks. I had been looking for that all day, but didn't realize it was bundled there.

Ryan
Reply all
Reply to author
Forward
0 new messages