How can I modify this Anchor tutorial code
in a way so when any non-authority wallet tries to update the count
variable it will give a message with an error like only owner can modify the value
?
1 Answer
First, you need to create an error, the message will be sent when the error is thrown
#[error_code]
pub enum ErrorCode {
#[msg("This is an ERROR!")]
MyCustomError,
}
then in your instruction
if something_is_wrong {
return Err(error!(ErrorCode::DrawAlreadyOffered));
}
-
That's another question that needs to have a seperate post. Please open another post, thank you :))– vicyynCommented Aug 23, 2022 at 11:24