eo_js: Instead of abort, throw an Exception
* When the constructor fails * On cast error.
This commit is contained in:
parent
c364844f67
commit
c08eedfd11
|
@ -917,6 +917,8 @@ compatibility_return_type cast_function(compatibility_callback_info_type args)
|
|||
auto isolate = args.GetIsolate();
|
||||
compatibility_handle_scope scope(isolate);
|
||||
v8::Local<v8::Value> type;
|
||||
try
|
||||
{
|
||||
if(args.Length() == 1 && (type = args[0])->IsString())
|
||||
{
|
||||
v8::Local<v8::Object> self = args.This();
|
||||
|
@ -932,10 +934,15 @@ compatibility_return_type cast_function(compatibility_callback_info_type args)
|
|||
return compatibility_return(obj, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::runtime_error("Type expected is different. Expected String type");
|
||||
}
|
||||
}
|
||||
catch (std::runtime_error const& error)
|
||||
{
|
||||
eina::js::compatibility_throw
|
||||
(isolate, v8::Exception::TypeError
|
||||
(eina::js::compatibility_new<v8::String>(isolate, "Type expected is different. Expected String type")));
|
||||
(eina::js::compatibility_new<v8::String>(isolate, error.what())));
|
||||
return compatibility_return();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,10 +68,7 @@ struct constructor_caller
|
|||
}
|
||||
else
|
||||
{
|
||||
eina::js::compatibility_throw
|
||||
(v8::Exception::TypeError
|
||||
(eina::js::compatibility_new<v8::String>(args->GetIsolate(), "Expected more arguments for this call")));
|
||||
throw std::logic_error("");
|
||||
throw std::logic_error("Expected more arguments for this call");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +111,8 @@ struct constructor_caller
|
|||
, parent
|
||||
, eina::_mpl::for_each(constructors, call{eo_self, ¤t_index, &args})
|
||||
);
|
||||
assert(eo != 0);
|
||||
if (!eo)
|
||||
throw std::logic_error("Failed to create object.");
|
||||
v8::Local<v8::Object> self = args.This();
|
||||
self->SetInternalField(0, eina::js::compatibility_new<v8::External>(args.GetIsolate(), eo));
|
||||
efl::eina::js::make_weak(args.GetIsolate(), self
|
||||
|
@ -123,7 +121,12 @@ struct constructor_caller
|
|||
eo_unref(eo);
|
||||
});
|
||||
}
|
||||
catch(std::logic_error const&) {}
|
||||
catch(std::logic_error const& error)
|
||||
{
|
||||
eina::js::compatibility_throw
|
||||
(v8::Exception::TypeError
|
||||
(eina::js::compatibility_new<v8::String>(args.GetIsolate(), error.what())));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue