use candid::CandidType;
use serde::Deserialize;
#[derive(CandidType, Deserialize, Debug, Clone)]
pub struct CanisterCallError {
pub canister_id: crate::identity::CanisterId,
pub method: String,
pub rejection_code: ic_cdk::api::call::RejectionCode,
pub message: std::string::String,
}
impl std::fmt::Display for CanisterCallError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"Canister({}) call({}) failed. {:?} ({})",
self.canister_id.to_text(),
self.method,
self.rejection_code,
self.message
)
}
}
impl std::error::Error for CanisterCallError {}
pub type CanisterCallResult<T> = Result<T, CanisterCallError>;
pub use super::codes::{CanisterCodeWasm, CanisterInitArg};