`Throw` no longer implements `Error`.
//! Types and traits for working with JavaScript exceptions.
-use std::error::Error;
use std::fmt::{Display, Formatter, Result as FmtResult};
use handle::Handle;
use types::Value;
use context::Context;
-/// An error sentinel type used by `NeonResult` (and `JsResult`) to indicate that the JS engine has entered into a throwing state.
+/// An error sentinel type used by `NeonResult` (and `JsResult`) to indicate that the JavaScript engine
+/// has entered into a throwing state.
+///
+/// `Throw` deliberately does not implement `std::error::Error`, because it's generally not a good idea
+/// to chain JavaScript exceptions with other kinds of Rust errors, since entering into the throwing
+/// state means that the JavaScript engine is unavailable until the exception is handled.
#[derive(Debug)]
pub struct Throw;
@@ -16,12 +20,6 @@ impl Display for Throw {
}
}
-impl Error for Throw {
- fn description(&self) -> &str {
- "javascript error"
- }
-}
-
/// The result of a computation that might send the JS engine into a throwing state.
pub type NeonResult<T> = Result<T, Throw>;
