Skip to content

Commit

Permalink
Don't reset exception handle after calling ErrWithV8Handle::get_handl…
Browse files Browse the repository at this point in the history
…e() (denoland#4214)
  • Loading branch information
piscisaureus committed Mar 2, 2020
1 parent 83d902a commit 3fcbf87
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
15 changes: 5 additions & 10 deletions core/es_isolate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,19 +315,14 @@ impl EsIsolate {
let mut resolver = resolver_handle.get(scope).unwrap();
resolver_handle.reset(scope);

let exception = match ErrBox::downcast::<ErrWithV8Handle>(err) {
Ok(mut err) => {
let handle = err.get_handle();
let exception = handle.get(scope).unwrap();
handle.reset(scope);
exception
}
Err(err) => {
let exception = err
.downcast_ref::<ErrWithV8Handle>()
.and_then(|err| err.get_handle().get(scope))
.unwrap_or_else(|| {
let message = err.to_string();
let message = v8::String::new(scope, &message).unwrap();
v8::Exception::type_error(scope, message)
}
};
});

resolver.reject(context, exception).unwrap();
scope.isolate().run_microtasks();
Expand Down
4 changes: 2 additions & 2 deletions core/isolate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,8 +1164,8 @@ impl ErrWithV8Handle {
Self { err, handle }
}

pub fn get_handle(&mut self) -> &mut v8::Global<v8::Value> {
&mut self.handle
pub fn get_handle(&self) -> &v8::Global<v8::Value> {
&self.handle
}
}

Expand Down

0 comments on commit 3fcbf87

Please sign in to comment.