From d434746a4649b69c57a2f749b4f7e848b63cedf6 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Tue, 16 Jun 2015 16:42:33 +0300 Subject: [PATCH] Better error messages Use the error message passed by the error exception instead of always reporting "Error rendering image". --- src/node_map.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/node_map.cpp b/src/node_map.cpp index 89ba8d3b9..9a21decd5 100644 --- a/src/node_map.cpp +++ b/src/node_map.cpp @@ -229,13 +229,22 @@ void NodeMap::renderFinished() { assert(!image); if (error) { + std::string errorMessage; + + try { + std::rethrow_exception(error); + } catch (const std::exception& ex) { + errorMessage = ex.what(); + } + + v8::Local argv[] = { + NanError(errorMessage.c_str()) + }; + // This must be empty to be prepared for the next render call. error = nullptr; assert(!error); - v8::Local argv[] = { - NanError("Error rendering image") - }; cb->Call(1, argv); } else if (img) { auto result = NanNew();