mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Merge generic funs to share them across all bindings (fixes #2684)
This commit is contained in:
parent
e7808c526c
commit
a90983553b
5 changed files with 185 additions and 200 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
//! Utilities to throw exceptions from Rust bindings.
|
||||
|
||||
use dom::bindings::codegen::PrototypeList::proto_id_to_name;
|
||||
use dom::bindings::conversions::ToJSValConvertible;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::domexception::{DOMException, DOMErrorName};
|
||||
|
@ -150,6 +151,15 @@ pub fn throw_not_in_union(cx: *mut JSContext, names: &'static str) {
|
|||
throw_type_error(cx, &error);
|
||||
}
|
||||
|
||||
/// Throw an exception to signal that a `JSObject` can not be converted to a
|
||||
/// given DOM type.
|
||||
pub fn throw_invalid_this(cx: *mut JSContext, proto_id: u16) {
|
||||
debug_assert!(unsafe { JS_IsExceptionPending(cx) } == 0);
|
||||
let error = format!("\"this\" object does not implement interface {}.",
|
||||
proto_id_to_name(proto_id));
|
||||
throw_type_error(cx, &error);
|
||||
}
|
||||
|
||||
/// Format string used to throw javascript errors.
|
||||
static ERROR_FORMAT_STRING_STRING: [libc::c_char; 4] = [
|
||||
'{' as libc::c_char,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue