aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/callback.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-06-14 12:17:21 -0600
committerbors-servo <metajack+bors@gmail.com>2015-06-14 12:17:21 -0600
commit24af4c4ec638b0484c8acacdf7cb9acb87da24ff (patch)
treec7ad8edda3ca468745b066c9e37411d39cb189ac /components/script/dom/bindings/callback.rs
parent6b886e545d04e75e10ea9db6ce4e2ca6d01b62c4 (diff)
parent5cc130727faf65d1da0261ee0ddfadb49c151869 (diff)
downloadservo-24af4c4ec638b0484c8acacdf7cb9acb87da24ff.tar.gz
servo-24af4c4ec638b0484c8acacdf7cb9acb87da24ff.zip
Auto merge of #6378 - Ms2ger:callable, r=nox
<!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6378) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/bindings/callback.rs')
-rw-r--r--components/script/dom/bindings/callback.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs
index 975e3cb99d9..4baccae098e 100644
--- a/components/script/dom/bindings/callback.rs
+++ b/components/script/dom/bindings/callback.rs
@@ -4,6 +4,7 @@
//! Base classes to work with IDL callbacks.
+use dom::bindings::error::{Fallible, Error};
use dom::bindings::global::global_object_for_js_object;
use dom::bindings::js::JSRef;
use dom::bindings::utils::Reflectable;
@@ -93,22 +94,20 @@ impl CallbackInterface {
}
/// Returns the property with the given `name`, if it is a callable object,
- /// or `Err(())` otherwise. If it returns `Err(())`, a JSAPI exception is
- /// pending.
+ /// or an error otherwise.
pub fn get_callable_property(&self, cx: *mut JSContext, name: &str)
- -> Result<JSVal, ()> {
+ -> Fallible<JSVal> {
let mut callable = UndefinedValue();
unsafe {
- let name = CString::new(name).unwrap();
- if JS_GetProperty(cx, self.callback(), name.as_ptr(), &mut callable) == 0 {
- return Err(());
+ let c_name = CString::new(name).unwrap();
+ if JS_GetProperty(cx, self.callback(), c_name.as_ptr(), &mut callable) == 0 {
+ return Err(Error::JSFailed);
}
if !callable.is_object() ||
JS_ObjectIsCallable(cx, callable.to_object()) == 0 {
- // FIXME(#347)
- //ThrowErrorMessage(cx, MSG_NOT_CALLABLE, description.get());
- return Err(());
+ return Err(Error::Type(
+ format!("The value of the {} property is not callable", name)));
}
}
Ok(callable)