-
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
Add context to multitest execution errors #597
Changes from 1 commit
b4e8e67
582e47e
0291e82
2c90217
05cf444
3eb5e2d
ad155f5
708e572
ef50e4b
ede69a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -319,13 +319,13 @@ impl<T1, T2, T3, E1, E2, E3, C, T4, E4, E5, T6, E6> Contract<C> | |
for ContractWrapper<T1, T2, T3, E1, E2, E3, C, T4, E4, E5, T6, E6> | ||
where | ||
T1: DeserializeOwned + Debug + Clone, | ||
T2: DeserializeOwned, | ||
T3: DeserializeOwned, | ||
T2: DeserializeOwned + Debug + Clone, | ||
T3: DeserializeOwned + Debug + Clone, | ||
T4: DeserializeOwned, | ||
T6: DeserializeOwned, | ||
E1: Display + Debug + Send + Sync + Error + 'static, | ||
E2: Display + Debug + Send + Sync + 'static, | ||
E3: Display + Debug + Send + Sync + 'static, | ||
E2: Display + Debug + Send + Sync + Error + 'static, | ||
E3: Display + Debug + Send + Sync + Error + 'static, | ||
E4: Display + Debug + Send + Sync + 'static, | ||
E5: Display + Debug + Send + Sync + 'static, | ||
E6: Display + Debug + Send + Sync + 'static, | ||
|
@@ -354,13 +354,23 @@ where | |
info: MessageInfo, | ||
msg: Vec<u8>, | ||
) -> AnyResult<Response<C>> { | ||
let msg = from_slice(&msg)?; | ||
(self.instantiate_fn)(deps, env, info, msg).map_err(|err| anyhow!(err)) | ||
let msg: T2 = from_slice(&msg)?; | ||
(self.instantiate_fn)(deps, env, info, msg.clone()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a thought, we could remove the let ctx = format!("Contract returned an error on instantiate msg:\n{:?}", msg);
(self.instantiate_fn)(deps, env, info, msg).map_err(anyhow::Error::from).context(ctx) Nothing really important, just like reducing required bounds and removing clones when possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, yeah, that looks much better. Will do 👍 |
||
.map_err(anyhow::Error::from) | ||
.context(format!( | ||
"Contract returned an error on instantiate msg:\n{:?}", | ||
msg, | ||
)) | ||
} | ||
|
||
fn query(&self, deps: Deps, env: Env, msg: Vec<u8>) -> AnyResult<Binary> { | ||
let msg = from_slice(&msg)?; | ||
(self.query_fn)(deps, env, msg).map_err(|err| anyhow!(err)) | ||
let msg: T3 = from_slice(&msg)?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks to add these two and the simple test. Looks good to me |
||
(self.query_fn)(deps, env, msg.clone()) | ||
.map_err(anyhow::Error::from) | ||
.context(format!( | ||
"Contract returned an error on query msg:\n{:?}", | ||
msg, | ||
)) | ||
} | ||
|
||
// this returns an error if the contract doesn't implement sudo | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would remove Clone from T1, T2, T3