You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In episode 4, after adding these guards for the error codes:
if topic.chars().count() > 50 {
return Err(ErrorCode::TopicTooLong.into())
}
if content.chars().count() > 280 {
return Err(ErrorCode::ContentTooLong.into())
}
I get compilation errors that look like
the trait bound `anchor_lang::prelude::ProgramError: From<ErrorCode>` is not satisfied
the following implementations were found:
<anchor_lang::prelude::ProgramError as From<PubkeyError>>
<anchor_lang::prelude::ProgramError as From<anchor_lang::error::Error>>
<anchor_lang::prelude::ProgramError as From<std::io::Error>>
<anchor_lang::prelude::ProgramError as From<u64>>
required because of the requirements on the impl of `Into<anchor_lang::prelude::ProgramError>` for `ErrorCode`
It seems that anchor 0.22.0 introduced breaking changes to error handling. After following the upgrade instructions from the anchor changelog, I got it to compile by changing the return type to Result<()>, and using the error! macro:
In episode 4, after adding these guards for the error codes:
I get compilation errors that look like
It seems that anchor 0.22.0 introduced breaking changes to error handling. After following the upgrade instructions from the anchor changelog, I got it to compile by changing the return type to
Result<()>
, and using theerror!
macro:I'm still working through the later episodes, so this may not be correct at run time, but it seems to compile at least.
The text was updated successfully, but these errors were encountered: