deft_quick_js/
exception.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use crate::JsValue;

pub trait HostPromiseRejectionTracker {
    fn track_promise_rejection(&mut self, promise: JsValue, reason: JsValue, is_handled: bool);
}

pub struct HostPromiseRejectionTrackerWrapper {
    pub tracker: Box<dyn HostPromiseRejectionTracker>,
}

impl HostPromiseRejectionTrackerWrapper {
    pub fn new(tracker: Box<dyn HostPromiseRejectionTracker>) -> Self {
        Self { tracker }
    }
}

pub struct DumpHostPromiseRejectionTracker {}

impl DumpHostPromiseRejectionTracker {
    pub fn new() -> Self {
        Self {}
    }
}

impl HostPromiseRejectionTracker for DumpHostPromiseRejectionTracker {
    fn track_promise_rejection(&mut self, _promise: JsValue, reason: JsValue, _is_handled: bool) {
        println!("uncaught promise rejection: {:?}", reason);
    }
}