diff --git a/src/binding.cc b/src/binding.cc index f2ceefc4..0dc722d9 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -129,6 +129,7 @@ public: { HandleScope scope; Connection *self = ObjectWrap::Unwrap(args.This()); + const char *lastErrorMessage; if(!args[0]->IsString()) { THROW("First parameter must be a string query"); } @@ -137,7 +138,8 @@ public: int result = self->Send(queryText); free(queryText); if(result == 0) { - THROW("PQsendQuery returned error code"); + lastErrorMessage = self->GetLastError(); + THROW(lastErrorMessage); } //TODO should we flush before throw? self->Flush(); @@ -615,6 +617,11 @@ private: { EmitError(PQerrorMessage(connection_)); } + + const char *GetLastError() + { + return PQerrorMessage(connection_); + } void StopWrite() {