rhaki_cw_multi_test/
error.rs1pub use anyhow::{anyhow, bail, Context as AnyContext, Error as AnyError, Result as AnyResult};
4use cosmwasm_std::{WasmMsg, WasmQuery};
5use thiserror::Error;
6
7#[derive(Debug, Error, PartialEq, Eq)]
9pub enum Error {
10 #[error("Empty attribute key. Value: {0}")]
12 EmptyAttributeKey(String),
13
14 #[error("Empty attribute value. Key: {0}")]
16 EmptyAttributeValue(String),
17
18 #[error("Attribute key starts with reserved prefix _: {0}")]
20 ReservedAttributeKey(String),
21
22 #[error("Event type too short: {0}")]
24 EventTypeTooShort(String),
25
26 #[error("Unsupported wasm query: {0:?}")]
28 UnsupportedWasmQuery(WasmQuery),
29
30 #[error("Unsupported wasm message: {0:?}")]
32 UnsupportedWasmMsg(WasmMsg),
33
34 #[error("code id: invalid")]
36 InvalidCodeId,
37
38 #[error("code id {0}: no such code")]
40 UnregisteredCodeId(u64),
41
42 #[error("duplicated code id {0}")]
44 DuplicatedCodeId(u64),
45
46 #[error("no more code identifiers available")]
48 NoMoreCodeIdAvailable,
49
50 #[error("Contract with this address already exists: {0}")]
52 DuplicatedContractAddress(String),
53}
54
55impl Error {
56 pub fn empty_attribute_key(value: impl Into<String>) -> Self {
58 Self::EmptyAttributeKey(value.into())
59 }
60
61 pub fn empty_attribute_value(key: impl Into<String>) -> Self {
63 Self::EmptyAttributeValue(key.into())
64 }
65
66 pub fn reserved_attribute_key(key: impl Into<String>) -> Self {
68 Self::ReservedAttributeKey(key.into())
69 }
70
71 pub fn event_type_too_short(ty: impl Into<String>) -> Self {
73 Self::EventTypeTooShort(ty.into())
74 }
75
76 pub fn unsupported_wasm_query(query: WasmQuery) -> Self {
78 Self::UnsupportedWasmQuery(query)
79 }
80
81 pub fn unsupported_wasm_message(msg: WasmMsg) -> Self {
83 Self::UnsupportedWasmMsg(msg)
84 }
85
86 pub fn invalid_code_id() -> Self {
88 Self::InvalidCodeId
89 }
90
91 pub fn unregistered_code_id(code_id: u64) -> Self {
93 Self::UnregisteredCodeId(code_id)
94 }
95
96 pub fn duplicated_code_id(code_id: u64) -> Self {
98 Self::DuplicatedCodeId(code_id)
99 }
100
101 pub fn no_more_code_id_available() -> Self {
103 Self::NoMoreCodeIdAvailable
104 }
105
106 pub fn duplicated_contract_address(address: impl Into<String>) -> Self {
108 Self::DuplicatedContractAddress(address.into())
109 }
110}