Skip to content

Commit

Permalink
Fail to construct if promise is none
Browse files Browse the repository at this point in the history
  • Loading branch information
CYBAI committed Nov 11, 2018
1 parent 19b4f35 commit 202d747
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions components/script/dom/promiserejectionevent.rs
Expand Up @@ -5,7 +5,7 @@
use crate::dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use crate::dom::bindings::codegen::Bindings::PromiseRejectionEventBinding;
use crate::dom::bindings::codegen::Bindings::PromiseRejectionEventBinding::PromiseRejectionEventMethods;
use crate::dom::bindings::error::Fallible;
use crate::dom::bindings::error::{Error, Fallible};
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::reflector::reflect_dom_object;
use crate::dom::bindings::root::DomRoot;
Expand Down Expand Up @@ -73,7 +73,11 @@ impl PromiseRejectionEvent {
let reason = init.reason.handle();
let promise = match init.promise.as_ref() {
Some(promise) => promise.clone(),
None => Promise::new(global),
None => {
return Err(Error::Type(
"required member promise is undefined.".to_string(),
))
},
};
let bubbles = EventBubbles::from(init.parent.bubbles);
let cancelable = EventCancelable::from(init.parent.cancelable);
Expand Down

0 comments on commit 202d747

Please sign in to comment.