diff options
author | Josh Matthews <josh@joshmatthews.net> | 2014-02-24 17:20:37 -0500 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2014-02-24 17:20:37 -0500 |
commit | 232ca597089cff647fcdef2a3cfd2030393ba84b (patch) | |
tree | ee406cede113b91d999fbc2ff806ebd2ad15de3f /src/components/script/dom/bindings/utils.rs | |
parent | 02d2ec5ccd4b4e52a1963e4fa844ce1e3e7b17ea (diff) | |
download | servo-232ca597089cff647fcdef2a3cfd2030393ba84b.tar.gz servo-232ca597089cff647fcdef2a3cfd2030393ba84b.zip |
Address review comments. Fix union conversion result mistakes introduced in refactoring.
Diffstat (limited to 'src/components/script/dom/bindings/utils.rs')
-rw-r--r-- | src/components/script/dom/bindings/utils.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs index 595d131c80c..80787d93416 100644 --- a/src/components/script/dom/bindings/utils.rs +++ b/src/components/script/dom/bindings/utils.rs @@ -879,6 +879,15 @@ pub fn throw_method_failed_with_details<T>(cx: *JSContext, return 0; } +pub fn throw_not_in_union(cx: *JSContext, names: &'static str) -> JSBool { + assert!(unsafe { JS_IsExceptionPending(cx) } == 0); + let message = format!("argument could not be converted to any of: {}", names); + message.with_c_str(|string| { + unsafe { ReportError(cx, string) }; + }); + return 0; +} + /// Execute arbitrary code with the JS GC enabled, then disable it afterwards. pub fn with_gc_enabled<R>(cx: *JSContext, f: || -> R) -> R { unsafe { |