Skip to content
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

Inspect why error no more includes a human-readable message #177

Closed
malikankit opened this issue Jun 15, 2021 · 4 comments
Closed

Inspect why error no more includes a human-readable message #177

malikankit opened this issue Jun 15, 2021 · 4 comments
Milestone

Comments

@malikankit
Copy link
Contributor

malikankit commented Jun 15, 2021

Cross-referencing comment (3 occurences) in tests/test_multisig.py

    # TODO: Previously the error included a human-readable message, why does it
    # only include the error code now? Something to do with different Anchor
    # versions?
@ruuda
Copy link
Contributor

ruuda commented Jun 16, 2021

Ah, I have a suspicion about what happened here ... I think the Anchor client might convert the error codes back to the message, and at some point maybe we switched how we call the program, so the Anchor client no longer had the opportunity to translate the error? We recently removed the Anchor client entirely, so now it’s even harder to translate it into a human-readable message ... but frankly I think these error codes are not useful, and the on-chain program should print the message to its log instead.

@malikankit malikankit added this to the V2 milestone Jul 12, 2021
@ruuda
Copy link
Contributor

ruuda commented Aug 6, 2021

I think it’s a problem with Anchor after all, maybe a bug introduced in a later version.

    let program_error = ProgramError::from(multisig::ErrorCode::AlreadyExecuted);
    println!("{:?}", program_error);
    let anchor_error = multisig::Error::from(program_error);
    println!("{:?}", anchor_error);

prints

Custom(105)
ProgramError(Custom(105))

while I would have expected it to print

Custom(105)
ErrorCode(AlreadyExecuted)

it seems that converting back the error code to the structured error is broken.

@ruuda
Copy link
Contributor

ruuda commented Aug 12, 2021

I believe I found the cause of this: coral-xyz/anchor#354 (comment)

@ruuda
Copy link
Contributor

ruuda commented Aug 13, 2021

#360 adds a workaround for this problem, so let’s close the issue.

@ruuda ruuda closed this as completed Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants