Is there a way to pass values to Anchor error messages that can be read by Anchor clients? Ex. How would I pass the value of data.data
below? If this is not possible, what is the best way to retrieve this value if running on devnet?
#[program]
mod hello_anchor {
use super::*;
pub fn set_data(ctx: Context<SetData>, data: MyAccount) -> Result<()> {
if data.data >= 100 {
return err!(MyError::DataTooLarge);
}
ctx.accounts.my_account.set_inner(data);
Ok(())
}
}
#[error_code]
pub enum MyError {
#[msg("MyAccount may only hold data below 100")]
DataTooLarge
}