-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Error redesign #1462
Error redesign #1462
Conversation
impl std::convert::From<Error> for anchor_lang::solana_program::program_error::ProgramError { | ||
fn from(e: Error) -> anchor_lang::solana_program::program_error::ProgramError { | ||
match e { | ||
Error::AnchorError(AnchorError { |
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.
No need to change. But FYI this can be rewritten as
AnchorError {
error_code_number,
..
}
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.
Looks good to go after the tests pass once more.
And what does |
the full expansion can be seen in lang/attribute/error
|
|
closes #798
Changes:
type Result<T> = Result<T, Error>
thats to be used instead ofProgramResult
error!
macro that createsAnchorError
with source info and wraps it inside anError
err!
macro that expands intoErr(error!(#error_code))
source!
macro that can be used to enrich ProgramErrors with Source information#[error]
to#[error_code]