1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use cosmwasm_std::{WasmMsg, WasmQuery};
use thiserror::Error;
#[derive(Debug, Error, PartialEq, Eq)]
pub enum Error {
#[error("Empty attribute key. Value: {value}")]
EmptyAttributeKey { value: String },
#[error("Empty attribute value. Key: {key}")]
EmptyAttributeValue { key: String },
#[error("Attribute key strats with reserved prefix _: {0}")]
ReservedAttributeKey(String),
#[error("Event type too short: {0}")]
EventTypeTooShort(String),
#[error("Unsupported wasm query: {0:?}")]
UnsupportedWasmQuery(WasmQuery),
#[error("Unsupported wasm message: {0:?}")]
UnsupportedWasmMsg(WasmMsg),
#[error("Unregistered code id")]
UnregisteredCodeId(usize),
}
impl Error {
pub fn empty_attribute_key(value: impl Into<String>) -> Self {
Self::EmptyAttributeKey {
value: value.into(),
}
}
pub fn empty_attribute_value(key: impl Into<String>) -> Self {
Self::EmptyAttributeValue { key: key.into() }
}
pub fn reserved_attribute_key(key: impl Into<String>) -> Self {
Self::ReservedAttributeKey(key.into())
}
pub fn event_type_too_short(ty: impl Into<String>) -> Self {
Self::EventTypeTooShort(ty.into())
}
}