Skip to content

Commit

Permalink
chore: use parse_err constructor instead of literal (#291)
Browse files Browse the repository at this point in the history
This PR applied `parse_err` constructor, it reduces a feature inside
`desmos-std-derive`.

See: CosmWasm/cosmwasm#1760
  • Loading branch information
dadamu committed Aug 28, 2023
1 parent 68c4aa5 commit e1251a2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type: refactor
module: none
pull_request: 291
description: Use `parse_err` constructor instead of literal
backward_compatible: false
date: 2023-08-18T07:06:29.63239721Z
3 changes: 0 additions & 3 deletions packages/std-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ version = "2.0.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
backtraces = ["cosmwasm-std/backtraces"]

[lib]
proc-macro = true

Expand Down
21 changes: 9 additions & 12 deletions packages/std-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,18 @@ pub fn derive_cosmwasm_ext(input: TokenStream) -> TokenStream {
fn try_from(binary: cosmwasm_std::Binary) -> std::result::Result<Self, Self::Error> {
use ::prost::Message;
Self::decode(&binary[..]).map_err(|e| {
cosmwasm_std::StdError::ParseErr {
target_type: stringify!(#ident).to_string(),
msg: format!(
"Unable to decode binary: \n - base64: {}\n - bytes array: {:?}\n\n{:?}",
binary,
binary.to_vec(),
e
),
#[cfg(feature = "backtraces")]
backtrace: std::backtrace::Backtrace::capture(),
}
cosmwasm_std::StdError::parse_err(stringify!(#ident).to_string(),
format!(
"Unable to decode binary: \n - base64: {}\n - bytes array: {:?}\n\n{:?}",
binary,
binary.to_vec(),
e
))
})
}
}
}).into()
})
.into()
}

fn get_type_url(attrs: &Vec<syn::Attribute>) -> proc_macro2::TokenStream {
Expand Down

0 comments on commit e1251a2

Please sign in to comment.