diff options
author | Kallyn Gowdy <kallyngowdy@gmail.com> | 2020-06-22 14:07:51 -0400 |
---|---|---|
committer | Kallyn Gowdy <kallyngowdy@gmail.com> | 2020-06-22 16:14:04 -0400 |
commit | 6a5a77a968898fac76df3cdf3c5b661be10e2f22 (patch) | |
tree | 9f1657467ced6486b68dfef93ed7dd1daab19937 /components/script/dom/bindings/error.rs | |
parent | f35f671f45ef1b589dec3bd9aa62fd4ae664e9e0 (diff) | |
download | servo-6a5a77a968898fac76df3cdf3c5b661be10e2f22.tar.gz servo-6a5a77a968898fac76df3cdf3c5b661be10e2f22.zip |
Fix building with --feature js_backtrace
- mozjs::jsapi::CapturedJSStack::as_string() (https://doc.servo.org/mozjs/rust/struct.CapturedJSStack.html#method.as_string) was updated to accept a second parameter which specifies which Stacktrace format to use. The default has been specified to preserve the (presumably) original behavior.
- The related code has also been placed in an unsafe block since the capture_stack macro calling the unsafe mozjs::jsapi::CapturedJSStack::new() function. Seems that this commit (https://github.com/servo/servo/commit/0703a1ad6d736796d467f5a028e5ab3c6d876268) forgot this part.
Diffstat (limited to 'components/script/dom/bindings/error.rs')
-rw-r--r-- | components/script/dom/bindings/error.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/components/script/dom/bindings/error.rs b/components/script/dom/bindings/error.rs index f678611423b..79cc8fbd869 100644 --- a/components/script/dom/bindings/error.rs +++ b/components/script/dom/bindings/error.rs @@ -23,6 +23,8 @@ use js::jsapi::ExceptionStackBehavior; use js::jsapi::JSContext; use js::jsapi::JS_ClearPendingException; use js::jsapi::JS_IsExceptionPending; +#[cfg(feature = "js_backtrace")] +use js::jsapi::StackFormat as JSStackFormat; use js::jsval::UndefinedValue; use js::rust::wrappers::JS_ErrorFromException; use js::rust::wrappers::JS_GetPendingException; @@ -108,9 +110,9 @@ pub type ErrorResult = Fallible<()>; /// Set a pending exception for the given `result` on `cx`. pub fn throw_dom_exception(cx: SafeJSContext, global: &GlobalScope, result: Error) { #[cfg(feature = "js_backtrace")] - { + unsafe { capture_stack!(in(*cx) let stack); - let js_stack = stack.and_then(|s| s.as_string(None)); + let js_stack = stack.and_then(|s| s.as_string(None, JSStackFormat::Default)); let rust_stack = Backtrace::new(); LAST_EXCEPTION_BACKTRACE.with(|backtrace| { *backtrace.borrow_mut() = Some((js_stack, format!("{:?}", rust_stack))); |