Add errors to declare program macro#3757
Conversation
|
@cryptopapi997 is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
|
@cryptopapi997 What is the purpose of this change? |
|
Had some client side error handling where depending on the error code I would handle the error differently. Currently this meant just copy pasting my error enum over from the program, which evidently silently broke the other day when we changed something in the errors in the program and forgot to update it in the client. This is a problem which is meant to be avoidable by having an idl that you just update once and then let changes propagate through |
|
Got it thanks for the explanation |
| /// Program error type definitions. | ||
| pub mod errors { | ||
|
|
||
| #[anchor_lang::error_code] |
There was a problem hiding this comment.
This might make the errors field of the IDL inconsistent during generation i.e. programs that use declare_program! might get external program errors in their own IDL. This is because the errors field of the IDL is populated via the same #[error_code] macro, meaning these declarations might conflict when there are multiple declarations in the same crate.
This is also why we manually declare the program ID in our declare_program! impl instead of just using declare_id! (#3555 (comment)).
Similar issue: #3438
* add errors to declare program macro * changelog and docs * cargo fmt
* add errors to declare program macro * changelog and docs * cargo fmt
Found myself needing this, so might as well add it.