Fix some styling of exception handling in JS wrappers

This commit is contained in:
Scott Kyle 2016-04-18 15:11:36 -07:00
parent 4731610a58
commit a0424c6600
3 changed files with 29 additions and 25 deletions

View File

@ -176,7 +176,7 @@ struct Object {
try { \
return Value<T>::validated_to_##type(ctx, get_property(ctx, object, key), std::string(key).c_str()); \
} \
catch(std::invalid_argument &e) { \
catch (std::invalid_argument &e) { \
throw message ? std::invalid_argument(message) : e; \
} \
} \
@ -184,7 +184,7 @@ struct Object {
try { \
return Value<T>::validated_to_##type(ctx, get_property(ctx, object, index)); \
} \
catch(std::invalid_argument &e) { \
catch (std::invalid_argument &e) { \
throw message ? std::invalid_argument(message) : e; \
} \
}

View File

@ -230,7 +230,7 @@ inline JSObjectRef ObjectWrap<ClassType>::construct(JSContextRef ctx, JSObjectRe
try {
s_class.constructor(ctx, this_object, argc, arguments);
}
catch(std::exception &e) {
catch (std::exception &e) {
*exception = jsc::Exception::value(ctx, e);
}
return this_object;
@ -328,11 +328,12 @@ JSValueRef wrap(JSContextRef ctx, JSObjectRef function, JSObjectRef this_object,
jsc::ReturnValue return_value(ctx);
try {
F(ctx, this_object, argc, arguments, return_value);
return return_value;
}
catch(std::exception &e) {
catch (std::exception &e) {
*exception = jsc::Exception::value(ctx, e);
return nullptr;
}
return return_value;
}
template<jsc::PropertyType::GetterType F>
@ -340,11 +341,12 @@ JSValueRef wrap(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSVa
jsc::ReturnValue return_value(ctx);
try {
F(ctx, object, return_value);
return return_value;
}
catch(std::exception &e) {
catch (std::exception &e) {
*exception = jsc::Exception::value(ctx, e);
return nullptr;
}
return return_value;
}
template<jsc::PropertyType::SetterType F>
@ -353,10 +355,10 @@ bool wrap(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSValueRef
F(ctx, object, value);
return true;
}
catch(std::exception &e) {
catch (std::exception &e) {
*exception = jsc::Exception::value(ctx, e);
return false;
}
return false;
}
template<jsc::IndexPropertyType::GetterType F>
@ -364,15 +366,16 @@ JSValueRef wrap(JSContextRef ctx, JSObjectRef object, uint32_t index, JSValueRef
jsc::ReturnValue return_value(ctx);
try {
F(ctx, object, index, return_value);
return return_value;
}
catch (std::out_of_range &) {
// Out-of-bounds index getters should just return undefined in JS.
return jsc::Value::from_undefined(ctx);
}
catch(std::exception &e) {
catch (std::exception &e) {
*exception = jsc::Exception::value(ctx, e);
return nullptr;
}
return return_value;
}
template<jsc::IndexPropertyType::SetterType F>
@ -380,10 +383,10 @@ bool wrap(JSContextRef ctx, JSObjectRef object, uint32_t index, JSValueRef value
try {
return F(ctx, object, index, value);
}
catch(std::exception &e) {
catch (std::exception &e) {
*exception = jsc::Exception::value(ctx, e);
return false;
}
return false;
}
template<jsc::StringPropertyType::GetterType F>
@ -391,11 +394,12 @@ JSValueRef wrap(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSVa
jsc::ReturnValue return_value(ctx);
try {
F(ctx, object, property, return_value);
return return_value;
}
catch(std::exception &e) {
catch (std::exception &e) {
*exception = jsc::Exception::value(ctx, e);
return nullptr;
}
return return_value;
}
template<jsc::StringPropertyType::SetterType F>
@ -403,10 +407,10 @@ bool wrap(JSContextRef ctx, JSObjectRef object, JSStringRef property, JSValueRef
try {
return F(ctx, object, property, value);
}
catch(std::exception &e) {
catch (std::exception &e) {
*exception = jsc::Exception::value(ctx, e);
return false;
}
return false;
}
template<jsc::StringPropertyType::EnumeratorType F>

View File

@ -239,7 +239,7 @@ inline void ObjectWrap<ClassType>::construct(Nan::NAN_METHOD_ARGS_TYPE info) {
try {
s_class.constructor(isolate, this_object, arguments.size(), arguments.data());
}
catch(std::exception &e) {
catch (std::exception &e) {
Nan::ThrowError(node::Exception::value(isolate, e));
}
}
@ -303,7 +303,7 @@ void wrap(Nan::NAN_METHOD_ARGS_TYPE info) {
try {
F(isolate, info.This(), arguments.size(), arguments.data(), return_value);
}
catch(std::exception &e) {
catch (std::exception &e) {
Nan::ThrowError(node::Exception::value(isolate, e));
}
}
@ -315,7 +315,7 @@ void wrap(v8::Local<v8::String> property, Nan::NAN_GETTER_ARGS_TYPE info) {
try {
F(isolate, info.This(), return_value);
}
catch(std::exception &e) {
catch (std::exception &e) {
Nan::ThrowError(node::Exception::value(isolate, e));
}
}
@ -326,7 +326,7 @@ void wrap(v8::Local<v8::String> property, v8::Local<v8::Value> value, Nan::NAN_S
try {
F(isolate, info.This(), value);
}
catch(std::exception &e) {
catch (std::exception &e) {
Nan::ThrowError(node::Exception::value(isolate, e));
}
}
@ -342,7 +342,7 @@ void wrap(uint32_t index, Nan::NAN_INDEX_GETTER_ARGS_TYPE info) {
// Out-of-bounds index getters should just return undefined in JS.
return_value.set_undefined();
}
catch(std::exception &e) {
catch (std::exception &e) {
Nan::ThrowError(node::Exception::value(isolate, e));
}
}
@ -356,7 +356,7 @@ void wrap(uint32_t index, v8::Local<v8::Value> value, Nan::NAN_INDEX_SETTER_ARGS
info.GetReturnValue().Set(value);
}
}
catch(std::exception &e) {
catch (std::exception &e) {
Nan::ThrowError(node::Exception::value(isolate, e));
}
}
@ -368,7 +368,7 @@ void wrap(v8::Local<v8::String> property, Nan::NAN_PROPERTY_GETTER_ARGS_TYPE inf
try {
F(isolate, info.This(), property, return_value);
}
catch(std::exception &e) {
catch (std::exception &e) {
Nan::ThrowError(node::Exception::value(isolate, e));
}
}
@ -382,7 +382,7 @@ void wrap(v8::Local<v8::String> property, v8::Local<v8::Value> value, Nan::NAN_P
info.GetReturnValue().Set(value);
}
}
catch(std::exception &e) {
catch (std::exception &e) {
Nan::ThrowError(node::Exception::value(isolate, e));
}
}