mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
make report_pending_exception safe and adjust callers (#35351)
Signed-off-by: Nolen Scaife <nolen@scaife.org>
This commit is contained in:
parent
827012fc08
commit
df73d02932
8 changed files with 42 additions and 44 deletions
|
@ -271,31 +271,35 @@ impl ErrorInfo {
|
|||
///
|
||||
/// The `dispatch_event` argument is temporary and non-standard; passing false
|
||||
/// prevents dispatching the `error` event.
|
||||
pub(crate) unsafe fn report_pending_exception(
|
||||
cx: *mut JSContext,
|
||||
pub(crate) fn report_pending_exception(
|
||||
cx: SafeJSContext,
|
||||
dispatch_event: bool,
|
||||
realm: InRealm,
|
||||
can_gc: CanGc,
|
||||
) {
|
||||
let cx = SafeJSContext::from_ptr(cx);
|
||||
if !JS_IsExceptionPending(*cx) {
|
||||
return;
|
||||
unsafe {
|
||||
if !JS_IsExceptionPending(*cx) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rooted!(in(*cx) let mut value = UndefinedValue());
|
||||
if !JS_GetPendingException(*cx, value.handle_mut()) {
|
||||
JS_ClearPendingException(*cx);
|
||||
error!("Uncaught exception: JS_GetPendingException failed");
|
||||
return;
|
||||
}
|
||||
|
||||
JS_ClearPendingException(*cx);
|
||||
unsafe {
|
||||
if !JS_GetPendingException(*cx, value.handle_mut()) {
|
||||
JS_ClearPendingException(*cx);
|
||||
error!("Uncaught exception: JS_GetPendingException failed");
|
||||
return;
|
||||
}
|
||||
|
||||
JS_ClearPendingException(*cx);
|
||||
}
|
||||
let error_info = ErrorInfo::from_value(value.handle(), cx);
|
||||
|
||||
error!(
|
||||
"Error at {}:{}:{} {}",
|
||||
error_info.filename, error_info.lineno, error_info.column, error_info.message
|
||||
);
|
||||
|
||||
#[cfg(feature = "js_backtrace")]
|
||||
{
|
||||
LAST_EXCEPTION_BACKTRACE.with(|backtrace| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue