summaryrefslogtreecommitdiff
path: root/core/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'core/error.rs')
-rw-r--r--core/error.rs26
1 files changed, 11 insertions, 15 deletions
diff --git a/core/error.rs b/core/error.rs
index f193c13e2..664cb5c0b 100644
--- a/core/error.rs
+++ b/core/error.rs
@@ -192,20 +192,17 @@ impl JsError {
let msg = v8::Exception::create_message(scope, exception);
let mut exception_message = None;
- // Nest this state borrow. A mutable borrow can occur when accessing `stack`
- // in this outer scope, invoking `Error.prepareStackTrace()` which calls
- // `op_apply_source_map`.
- {
- let state_rc = JsRuntime::state(scope);
- let state = state_rc.borrow();
- if let Some(format_exception_cb) = &state.js_format_exception_cb {
- let format_exception_cb = format_exception_cb.open(scope);
- let this = v8::undefined(scope).into();
- let formatted = format_exception_cb.call(scope, this, &[exception]);
- if let Some(formatted) = formatted {
- if formatted.is_string() {
- exception_message = Some(formatted.to_rust_string_lossy(scope));
- }
+ let state_rc = JsRuntime::state(scope);
+
+ let js_format_exception_cb =
+ state_rc.borrow().js_format_exception_cb.clone();
+ if let Some(format_exception_cb) = js_format_exception_cb {
+ let format_exception_cb = format_exception_cb.open(scope);
+ let this = v8::undefined(scope).into();
+ let formatted = format_exception_cb.call(scope, this, &[exception]);
+ if let Some(formatted) = formatted {
+ if formatted.is_string() {
+ exception_message = Some(formatted.to_rust_string_lossy(scope));
}
}
}
@@ -263,7 +260,6 @@ impl JsError {
let mut source_line = None;
let mut source_line_frame_index = None;
{
- let state_rc = JsRuntime::state(scope);
let state = &mut *state_rc.borrow_mut();
// When the stack frame array is empty, but the source location given by