Skip to content

Commit

Permalink
chore: Better error message for sv::features attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
jawoznia committed Oct 16, 2024
1 parent 689607c commit b7b32c2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions sylvia-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,15 @@ fn interface_impl(_attr: TokenStream2, item: TokenStream2) -> TokenStream2 {
///
/// Currently supported features are:
/// * `replies` - enables better dispatching of `reply` as well as its auto deserialization.
/// With this feature enabled, user can use additional parameters in the
/// `sv::msg` attribute like so:
/// `#[sv::msg(reply, handlers=[scenario1, scenario2], reply_on=Success)].
///
/// Based on this parameters reply ids will be generated and associated with
/// proper scenario specified by the `reply_on` parameter.
///
/// User can also specify custom `data` and `payload` types that will be auto
/// deserialized from the `cosmwasm_std::Binary` type.
#[proc_macro_error]
#[proc_macro_attribute]
pub fn contract(attr: TokenStream, item: TokenStream) -> TokenStream {
Expand Down
2 changes: 1 addition & 1 deletion sylvia-derive/src/parser/attributes/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Parse for SylviaFeatures {
_ => {
return Err(Error::new(
feature.span(),
"Invalid feature.\n= note: Expected `#[sv::features(replies)];`.\n",
"Invalid feature.\n= note: Supported features for contract macro: [`replies`].\n",

Check warning on line 34 in sylvia-derive/src/parser/attributes/features.rs

View check run for this annotation

Codecov / codecov/patch

sylvia-derive/src/parser/attributes/features.rs#L32-L34

Added lines #L32 - L34 were not covered by tests
))
}
}
Expand Down
2 changes: 1 addition & 1 deletion sylvia/tests/ui/attributes/features/invalid_params.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: Invalid feature.
= note: Expected `#[sv::features(replies)];`.
= note: Supported features for contract macro: [`replies`].
--> tests/ui/attributes/features/invalid_params.rs:9:16
|
9 | #[sv::features(unknown_parameter)]
Expand Down

0 comments on commit b7b32c2

Please sign in to comment.