Skip to content

Commit

Permalink
Rethrow async cb error as JS exception
Browse files Browse the repository at this point in the history
After nodejs/node#12838 is merged, the exception will be properly reported.
  • Loading branch information
jasongin committed May 4, 2017
1 parent 4236269 commit cb46bc5
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2684,16 +2684,7 @@ inline void AsyncWorker::OnWorkComplete(
self->OnError(Error::New(self->_env, self->_error));
}
} catch (const Error& e) {
// A JS or N-API exception was thrown, and propagated as a C++ exception.
// But throwing a JS exception here would have no effect because there
// is no JS on the callstack.

// TODO: Print the exception details and abort, just like Node.js normally
// does for unhandled exceptions. But there is no N-API function for that.
// For now just assert, so at least the exception message is discoverable
// in a debug build.
const char* message = e.what();
assert(false);
e.ThrowAsJavaScriptException();
}
}
delete self;
Expand Down

0 comments on commit cb46bc5

Please sign in to comment.