Invert conditional and return early from report_pending_exception

This commit is contained in:
Florian Hartwig 2016-10-13 23:28:24 +02:00
parent 3916d1d613
commit f064d9ad83

View file

@ -202,7 +202,8 @@ impl ErrorInfo {
/// The `dispatch_event` argument is temporary and non-standard; passing false
/// prevents dispatching the `error` event.
pub unsafe fn report_pending_exception(cx: *mut JSContext, dispatch_event: bool) {
if JS_IsExceptionPending(cx) {
if !JS_IsExceptionPending(cx) { return; }
rooted!(in(cx) let mut value = UndefinedValue());
if !JS_GetPendingException(cx, value.handle_mut()) {
JS_ClearPendingException(cx);
@ -249,7 +250,6 @@ pub unsafe fn report_pending_exception(cx: *mut JSContext, dispatch_event: bool)
.report_an_error(error_info, value.handle());
}
}
}
/// Throw an exception to signal that a `JSVal` can not be converted to any of
/// the types in an IDL union type.