Skip to content

Commit

Permalink
Auto merge of #12272 - Ms2ger:report, r=jdm
Browse files Browse the repository at this point in the history
Reuse report_pending_exception in CallSetup.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12272)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Jul 7, 2016
2 parents 32fa565 + 7254000 commit 4fafcb1
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions components/script/dom/bindings/callback.rs
Expand Up @@ -4,15 +4,14 @@

//! Base classes to work with IDL callbacks.

use dom::bindings::error::{Error, Fallible};
use dom::bindings::error::{Error, Fallible, report_pending_exception};
use dom::bindings::global::global_root_from_object;
use dom::bindings::reflector::Reflectable;
use js::jsapi::GetGlobalForObjectCrossCompartment;
use js::jsapi::JSAutoCompartment;
use js::jsapi::JS_GetProperty;
use js::jsapi::{Heap, MutableHandleObject, RootedObject};
use js::jsapi::{IsCallable, JSContext, JSObject, JS_WrapObject};
use js::jsapi::{JSCompartment, JS_EnterCompartment, JS_LeaveCompartment};
use js::jsapi::{JS_GetProperty, JS_IsExceptionPending, JS_ReportPendingException};
use js::jsval::{JSVal, UndefinedValue};
use js::rust::RootedGuard;
use std::default::Default;
Expand Down Expand Up @@ -189,13 +188,8 @@ impl<'a> Drop for CallSetup<'a> {
fn drop(&mut self) {
unsafe {
JS_LeaveCompartment(self.cx, self.old_compartment);
}
let need_to_deal_with_exception = self.handling == ExceptionHandling::Report &&
unsafe { JS_IsExceptionPending(self.cx) };
if need_to_deal_with_exception {
unsafe {
let _ac = JSAutoCompartment::new(self.cx, *self.exception_compartment);
JS_ReportPendingException(self.cx);
if self.handling == ExceptionHandling::Report {
report_pending_exception(self.cx, *self.exception_compartment);
}
}
}
Expand Down

0 comments on commit 4fafcb1

Please sign in to comment.