Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
error renaming
  • Loading branch information
pmikolajczyk41 committed Sep 13, 2022
commit 96d0d24ec1362f45c9017d2edfc312deef28bb20
10 changes: 6 additions & 4 deletions contracts/button/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@ pub enum GameError {
AfterDeadline,
/// Call has been made from an account with missing access control privileges
MissingRole(Role),
/// Returned if a call to another contract has failed
CrossContractCallFailed(String),
/// A call to a PSP22 contract has failed
PSP22Error(PSP22Error),
/// An interaction with ink! environment has failed
InkEnvError(String),
/// Couldn't have retrieved own code hash
CantRetrieveOwnCodeHash,
}

impl From<PSP22Error> for GameError {
fn from(e: PSP22Error) -> Self {
GameError::CrossContractCallFailed(format!("{:?}", e))
GameError::PSP22Error(e)
}
}

impl From<InkEnvError> for GameError {
fn from(e: InkEnvError) -> Self {
GameError::CrossContractCallFailed(format!("Contract call failed due to {:?}", e))
GameError::InkEnvError(format!("{:?}", e))
}
}
5 changes: 1 addition & 4 deletions contracts/button/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,7 @@ mod button_game {
account.clone(),
role,
|why: InkEnvError| {
GameError::CrossContractCallFailed(format!(
"Calling access control has failed: {:?}",
why
))
GameError::InkEnvError(format!("Calling access control has failed: {:?}", why))
},
|role: Role| GameError::MissingRole(role),
)
Expand Down