Native Module - Code review request, and some doubts

37 views
Skip to first unread message

Jonathan Cardoso

unread,
Sep 10, 2014, 3:29:04 PM9/10/14
to nod...@googlegroups.com
Currently I'm building a libcurl bindings for nodejs,  mostly for learning purposes, as I'm really new to C++ (like, this is my first time programming something in C++), so you can find it here: https://github.com/JCMais/node-libcurl

If anyone is willing to take a look at the code and give me any advices I would be really grateful.The main class is here: https://github.com/JCMais/node-libcurl/blob/develop/src/Curl.cc

Right now, I have some major doubts:

1. I should use HandleScope even on code executed by another thread? See this piece of code: https://github.com/JCMais/node-libcurl/blob/develop/src/Curl.cc#L409

If not, how I should throw the exception that is in there and return it?

2. Why the exception stack trace is lost when I throw an exception from inside a function called by the native module?

Ex: Inside the file examples\simple-request.js, if I replace the end event callback with:

throw Error( 'Something went wrong.' );

it shows the following:
.\examples\simple-request.js:599: Uncaught Error: Something went wrong.

Line is incorrect, and there is no stack trace. What is going on?

Thanks in advance.

Jonathan Cardoso

unread,
Sep 10, 2014, 8:54:06 PM9/10/14
to nod...@googlegroups.com
Ok, I found out why 2 was happening, it was because I was calling the function directly, without checking if any exceptions were throw, I'm using node::MakeCallback() now.
Reply all
Reply to author
Forward
0 new messages