Commit f6ebeab8 by Marcin Cieslak

Throw V8 exception on invalid Sass_Value

In the unlikely event libsass gives us the
value we don't understand use V8 exception
to report failure and exit before calling
a user-defined custom function.

XXX We do not have currently any way
    to test this (that would require mocking
    libsass).
parent dd1f3a9d
...@@ -98,7 +98,12 @@ T CallbackBridge<T, L>::operator()(std::vector<void*> argv) { ...@@ -98,7 +98,12 @@ T CallbackBridge<T, L>::operator()(std::vector<void*> argv) {
* post_process_args(). * post_process_args().
*/ */
Nan::HandleScope scope; Nan::HandleScope scope;
Nan::TryCatch try_catch;
std::vector<v8::Local<v8::Value>> argv_v8 = pre_process_args(argv); std::vector<v8::Local<v8::Value>> argv_v8 = pre_process_args(argv);
if (try_catch.HasCaught()) {
Nan::FatalException(try_catch);
}
argv_v8.push_back(Nan::New(wrapper)); argv_v8.push_back(Nan::New(wrapper));
return this->post_process_return_value( return this->post_process_return_value(
...@@ -149,6 +154,9 @@ void CallbackBridge<T, L>::dispatched_async_uv_callback(uv_async_t *req) { ...@@ -149,6 +154,9 @@ void CallbackBridge<T, L>::dispatched_async_uv_callback(uv_async_t *req) {
Nan::TryCatch try_catch; Nan::TryCatch try_catch;
std::vector<v8::Local<v8::Value>> argv_v8 = bridge->pre_process_args(bridge->argv); std::vector<v8::Local<v8::Value>> argv_v8 = bridge->pre_process_args(bridge->argv);
if (try_catch.HasCaught()) {
Nan::FatalException(try_catch);
}
argv_v8.push_back(Nan::New(bridge->wrapper)); argv_v8.push_back(Nan::New(bridge->wrapper));
bridge->callback->Call(argv_v8.size(), &argv_v8[0]); bridge->callback->Call(argv_v8.size(), &argv_v8[0]);
......
...@@ -39,7 +39,9 @@ namespace SassTypes ...@@ -39,7 +39,9 @@ namespace SassTypes
return new Error(v); return new Error(v);
default: default:
throw std::invalid_argument("Unknown type encountered."); const char *msg = "Unknown type encountered.";
Nan::ThrowTypeError(Nan::New<v8::String>(msg).ToLocalChecked());
return new Error(sass_make_error(msg));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment