Make `throw` a method of `Context`.
@@ -220,14 +220,6 @@ impl Error for Throw {
}
}
-/// Throws a JS value.
-pub fn throw<'a, 'b, C: Context<'a>, T: Value, U>(_: &mut C, v: Handle<'b, T>) -> VmResult<U> {
- unsafe {
- neon_runtime::error::throw(v.to_raw());
- }
- Err(Throw)
-}
-
/// The result of a computation that might send the JS VM into a throwing state.
pub type VmResult<T> = Result<T, Throw>;
@@ -539,6 +531,14 @@ pub trait Context<'a>: ContextInternal<'a> {
}
})
}
+
+ /// Throws a JS value.
+ fn throw<'b, T: Value, U>(&mut self, v: Handle<'b, T>) -> VmResult<U> {
+ unsafe {
+ neon_runtime::error::throw(v.to_raw());
+ }
+ Err(Throw)
+ }
}
/// A view of the JS VM in the context of top-level initialization of a Neon module.
