trident icon indicating copy to clipboard operation
trident copied to clipboard

More user friendly Anchor error codes

Open DXist opened this issue 2 years ago • 2 comments

I came across multiple Anchor errors like

 RPC response error -32002: Transaction simulation failed: Error processing Instruction 0: custom program error: 0xbc4

It would be more helpful instead of hex codes to get user friendly error output based on https://docs.rs/anchor-lang/latest/src/anchor_lang/error.rs.html#22

DXist avatar Jul 17 '22 09:07 DXist

Hey @DXist!

Thank you for the report! We are not handling the anchor errors and it's not our priority to do so right now but if you want, you can take a look at it and create a PR :muscle:

If you have a problem like this, just convert the 0xbc4 to decimal number and try to find it in anchor docs: https://docs.rs/anchor-lang/latest/anchor_lang/error/enum.ErrorCode.html.

Your error is 3012 which should be this one: https://docs.rs/anchor-lang/latest/anchor_lang/error/enum.ErrorCode.html#variant.AccountNotInitialized

stefanprokopdev avatar Jul 18 '22 07:07 stefanprokopdev

Yes, I've converted these codes manually. But it took me some time to understand that this error code comes from Anchor and to find the enum with codes.

If it's not possible to separate Anchor error codes from error codes of other programs then it would be good enough just to convert it to decimal value and provide the link to the enum documentation.

Can we introduce 'improvement' label for this issue to mark low priority status?

DXist avatar Jul 18 '22 08:07 DXist