Skip to content

Commit

Permalink
fix to_bigint unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
fatcat22 committed May 16, 2023
1 parent 1e683ae commit 2d71e03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/brc20/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<L: LedgerRead> From<BRC20Error> for Error<L> {
Expand Down
5 changes: 4 additions & 1 deletion src/brc20/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit 2d71e03

Please sign in to comment.