Skip to content

Commit

Permalink
fix: use custom errors for the runtime
Browse files Browse the repository at this point in the history
Fixes #196
  • Loading branch information
dignifiedquire committed Apr 7, 2022
1 parent e1f1d5a commit 036e230
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 145 deletions.
3 changes: 2 additions & 1 deletion actors/runtime/src/builtin/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use fvm_shared::address::Address;
use fvm_shared::METHOD_SEND;

use crate::runtime::Runtime;
use anyhow::Context;

pub const HAMT_BIT_WIDTH: u32 = 5;

Expand All @@ -24,7 +25,7 @@ where

// send 0 balance to the account so an ID address for it is created and then try to resolve
rt.send(*address, METHOD_SEND, Default::default(), Default::default())
.map_err(|e| e.wrap(&format!("failed to send zero balance to address {}", address)))?;
.with_context(|| format!("failed to send zero balance to address {}", address))?;

rt.resolve_address(address).ok_or_else(|| {
anyhow::anyhow!(
Expand Down
3 changes: 2 additions & 1 deletion actors/runtime/src/runtime/actor_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ pub trait ActorCode {
// hold onto state between transactions.
// https://github.com/filecoin-project/builtin-actors/issues/133
BS: Blockstore + Clone,
RT: Runtime<BS>;
RT: Runtime<BS>,
ActorError: From<RT::Error>;
}
Loading

0 comments on commit 036e230

Please sign in to comment.