diff --git a/src/brc20/error.rs b/src/brc20/error.rs index 04c21b9b10..a7d0aec516 100644 --- a/src/brc20/error.rs +++ b/src/brc20/error.rs @@ -81,6 +81,11 @@ pub enum BRC20Error { #[error("transferable owner not match {0}")] TransferableOwnerNotMatch(InscriptionId), + + /// an InternalError is an error that happens exceed our expect + /// and should not happen under normal circumstances + #[error("internal error: {0}")] + InternalError(String), } impl From for Error { diff --git a/src/brc20/num.rs b/src/brc20/num.rs index 50bdeed59b..24c81d197a 100644 --- a/src/brc20/num.rs +++ b/src/brc20/num.rs @@ -71,7 +71,10 @@ impl Num { self .0 .to_bigint() - .unwrap() + .ok_or(BRC20Error::InternalError(format!( + "convert {} to bigint failed", + self.0 + )))? .to_u128() .ok_or(BRC20Error::Overflow { op: String::from("to_u128"),