bn_rs/bn/error.rs
1use thiserror::Error;
2use wasm_bindgen::JsValue;
3
4#[derive(Error, Debug)]
5pub enum BNError {
6 #[error("cannot convert negative BN to uint")]
7 NegativeUint,
8 #[error("BN doesn't fit into {0}")]
9 Overflow(String),
10 #[error("BN threw {0}")]
11 Throw(String),
12}
13
14impl From<BNError> for JsValue {
15 fn from(err: BNError) -> Self {
16 format!("{:?}", err).into()
17 }
18}