mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
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 (0703a1ad6d
) forgot this part.
This commit is contained in:
parent
f35f671f45
commit
6a5a77a968
1 changed files with 4 additions and 2 deletions
|
@ -23,6 +23,8 @@ use js::jsapi::ExceptionStackBehavior;
|
||||||
use js::jsapi::JSContext;
|
use js::jsapi::JSContext;
|
||||||
use js::jsapi::JS_ClearPendingException;
|
use js::jsapi::JS_ClearPendingException;
|
||||||
use js::jsapi::JS_IsExceptionPending;
|
use js::jsapi::JS_IsExceptionPending;
|
||||||
|
#[cfg(feature = "js_backtrace")]
|
||||||
|
use js::jsapi::StackFormat as JSStackFormat;
|
||||||
use js::jsval::UndefinedValue;
|
use js::jsval::UndefinedValue;
|
||||||
use js::rust::wrappers::JS_ErrorFromException;
|
use js::rust::wrappers::JS_ErrorFromException;
|
||||||
use js::rust::wrappers::JS_GetPendingException;
|
use js::rust::wrappers::JS_GetPendingException;
|
||||||
|
@ -108,9 +110,9 @@ pub type ErrorResult = Fallible<()>;
|
||||||
/// Set a pending exception for the given `result` on `cx`.
|
/// Set a pending exception for the given `result` on `cx`.
|
||||||
pub fn throw_dom_exception(cx: SafeJSContext, global: &GlobalScope, result: Error) {
|
pub fn throw_dom_exception(cx: SafeJSContext, global: &GlobalScope, result: Error) {
|
||||||
#[cfg(feature = "js_backtrace")]
|
#[cfg(feature = "js_backtrace")]
|
||||||
{
|
unsafe {
|
||||||
capture_stack!(in(*cx) let stack);
|
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();
|
let rust_stack = Backtrace::new();
|
||||||
LAST_EXCEPTION_BACKTRACE.with(|backtrace| {
|
LAST_EXCEPTION_BACKTRACE.with(|backtrace| {
|
||||||
*backtrace.borrow_mut() = Some((js_stack, format!("{:?}", rust_stack)));
|
*backtrace.borrow_mut() = Some((js_stack, format!("{:?}", rust_stack)));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue