Skip to content

Commit

Permalink
Merge pull request joeferner#57 from raztus/master
Browse files Browse the repository at this point in the history
Handle exceptions within callback functions by calling node::FatalException()
  • Loading branch information
joeferner committed Jul 3, 2013
2 parents 762de43 + 077f193 commit c6feb9f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@ void Connection::EIO_AfterCommit(uv_work_t* req, int status) {

Handle<Value> argv[2];
argv[0] = Undefined();
v8::TryCatch tryCatch;
baton->callback->Call(Context::GetCurrent()->Global(), 1, argv);
if (tryCatch.HasCaught()) {
node::FatalException(tryCatch);
}

delete baton;
}
Expand All @@ -365,7 +369,11 @@ void Connection::EIO_AfterRollback(uv_work_t* req, int status) {

Handle<Value> argv[2];
argv[0] = Undefined();
v8::TryCatch tryCatch;
baton->callback->Call(Context::GetCurrent()->Global(), 1, argv);
if (tryCatch.HasCaught()) {
node::FatalException(tryCatch);
}

delete baton;
}
Expand Down Expand Up @@ -715,7 +723,11 @@ void Connection::EIO_AfterExecute(uv_work_t* req, int status) {
argv[1] = obj;
}
}
v8::TryCatch tryCatch;
baton->callback->Call(Context::GetCurrent()->Global(), 2, argv);
if (tryCatch.HasCaught()) {
node::FatalException(tryCatch);
}
} catch(NodeOracleException &ex) {
Handle<Value> argv[2];
argv[0] = Exception::Error(String::New(ex.getMessage().c_str()));
Expand Down
4 changes: 4 additions & 0 deletions src/oracle_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ void OracleClient::EIO_AfterConnect(uv_work_t* req, int status) {
argv[1] = connection;
}

v8::TryCatch tryCatch;
baton->callback->Call(Context::GetCurrent()->Global(), 2, argv);
if (tryCatch.HasCaught()) {
node::FatalException(tryCatch);
}

baton->callback.Dispose();
if(baton->error) delete baton->error;
Expand Down

0 comments on commit c6feb9f

Please sign in to comment.