Skip to content

Commit

Permalink
Throw type error on converting non objects to sequence, Don't panic i…
Browse files Browse the repository at this point in the history
…n case of JS error
  • Loading branch information
stspyder committed Feb 6, 2016
1 parent b96675b commit f2f0770
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ impl<C: Clone, T: FromJSValConvertible<Config=C>> FromJSValConvertible for Vec<T
let mut length = 0;

if !value.is_object() {
throw_type_error(cx, "Non objects cannot be converted to sequence");
return Err(())
}

Expand All @@ -508,7 +509,10 @@ impl<C: Clone, T: FromJSValConvertible<Config=C>> FromJSValConvertible for Vec<T

for i in 0..length {
let mut val = RootedValue::new(cx, UndefinedValue());
assert!(JS_GetElement(cx, obj.handle(), i, val.handle_mut()));
if !JS_GetElement(cx, obj.handle(), i, val.handle_mut()) {
// On JS Exception return Err
return Err(());
}
ret.push(try!(T::from_jsval(cx, val.handle(), option.clone())));
}

Expand Down

0 comments on commit f2f0770

Please sign in to comment.