-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration to 0.11: errors of shared functions accross contracts #103
Comments
Here is an example of mixed type implementations: https://github.com/CosmWasm/cosmwasm/blob/v0.11.0-alpha3/contracts/staking/src/contract.rs#L56-L69 You use HandleMsg::Freeze {} => Ok(handle_freeze(deps, env)?) to convert |
Thanks for the quick response! I'll try this and report back. |
This works, thanks. |
At least for StdError -> custom error we now recommend the use cosmwasm_std::{CanonicalAddr, StdError};
use thiserror::Error;
// thiserror implements Display and ToString if you
// set the `#[error("…")]` attribute for all cases
#[derive(Error, Debug)]
pub enum MyCustomError {
#[error("{0}")]
// let thiserror implement From<StdError> for you
Std(#[from] StdError),
// this is whatever we want
#[error("Permission denied: the sender is not the current owner")]
NotCurrentOwner {
expected: CanonicalAddr,
actual: CanonicalAddr,
},
#[error("Messages empty. Must reflect at least one message")]
MessagesEmpty,
} However, I don't know how this will look like if you need multiple of those container cases. |
Facing the following error migrating errors to the new format (i.e. to 0.11):
This is because
handle_freeze()
is being imported fromcw1-whitelist
, which has its ownContractError
.Opening this issue so we can document / discuss solutions to this.
The text was updated successfully, but these errors were encountered: