1use cosmwasm_std::{CoinsError, StdError};
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum ContractError {
6 #[error("{0}")]
7 Std(#[from] StdError),
8
9 #[error("Unauthorized")]
10 Unauthorized {},
11
12 #[error("Paused")]
13 Paused {},
14
15 #[error("InvalidMsg: {msg:?}")]
16 InvalidMsg { msg: String },
17
18 #[error("ContractLocked: {msg:?}")]
19 ContractLocked { msg: String },
20
21 #[error("InvalidState: {msg:?}")]
22 InvalidState { msg: String },
23
24 #[error("Semver parsing error: {0}")]
25 SemVer(String),
26
27 #[error("invalid coins: {0}")]
28 InvalidCoins(#[from] CoinsError),
29
30 #[error("InvalidMsg: {0}")]
31 UnsupportedOperation(String),
32}
33
34impl From<semver::Error> for ContractError {
35 fn from(err: semver::Error) -> Self {
36 Self::SemVer(err.to_string())
37 }
38}
39
40impl From<ContractError> for StdError {
41 fn from(err: ContractError) -> Self {
42 StdError::generic_err(err.to_string())
43 }
44}