@ -21,12 +21,16 @@
*/
#pragma once
#include <exception>
namespace dev
{
namespace eth
class JSException: public std::exception {};
class JSPrintException: public JSException { char const* what() const noexcept { return "Cannot print expression!"; } };
class JSString
public:
@ -35,7 +35,9 @@ namespace eth
static char const* toCString(v8::String::Utf8Value const& _value)
return *_value ? *_value : "<string conversion failed>";
if (*_value)
return *_value;
throw JSPrintException();
}
// from: https://github.com/v8/v8-git-mirror/blob/master/samples/shell.cc
@ -43,5 +43,7 @@ JSString JSV8Printer::prettyPrint(JSV8Value const& _value) const
v8::Local<v8::Value> values[1] = {v8::Local<v8::Value>::New(_value.value())};
v8::Local<v8::Value> res = func->Call(func, 1, values);
v8::String::Utf8Value str(res);
return *str ? *str : "<pretty print conversion failed>";
if (*str)
return *str;