From 077f1938de2ace6d1094611f2081fb3fe802c6f5 Mon Sep 17 00:00:00 2001 From: John Coulter Date: Tue, 2 Jul 2013 17:36:39 -0600 Subject: [PATCH] Add v8::TryCatch calls to handle exceptions in function callbacks --- src/connection.cpp | 12 ++++++++++++ src/oracle_bindings.cpp | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/src/connection.cpp b/src/connection.cpp index 0664149..42d5e5e 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -347,7 +347,11 @@ void Connection::EIO_AfterCommit(uv_work_t* req, int status) { Handle argv[2]; argv[0] = Undefined(); + v8::TryCatch tryCatch; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + if (tryCatch.HasCaught()) { + node::FatalException(tryCatch); + } delete baton; } @@ -365,7 +369,11 @@ void Connection::EIO_AfterRollback(uv_work_t* req, int status) { Handle argv[2]; argv[0] = Undefined(); + v8::TryCatch tryCatch; baton->callback->Call(Context::GetCurrent()->Global(), 1, argv); + if (tryCatch.HasCaught()) { + node::FatalException(tryCatch); + } delete baton; } @@ -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 argv[2]; argv[0] = Exception::Error(String::New(ex.getMessage().c_str())); diff --git a/src/oracle_bindings.cpp b/src/oracle_bindings.cpp index 8155341..330eca1 100644 --- a/src/oracle_bindings.cpp +++ b/src/oracle_bindings.cpp @@ -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;