Skip to content

lang: Fix missing error messages of the generated errors in declare_program!#4652

Merged
jamie-osec merged 3 commits into
otter-sec:masterfrom
acheroncrypto:lang-fix-missing-error-messages-of-the-generated-errors-in-declare_program
Jun 11, 2026
Merged

lang: Fix missing error messages of the generated errors in declare_program!#4652
jamie-osec merged 3 commits into
otter-sec:masterfrom
acheroncrypto:lang-fix-missing-error-messages-of-the-generated-errors-in-declare_program

Conversation

@acheroncrypto

Copy link
Copy Markdown
Collaborator

Problem

declare_program! doesn't account for custom error messages during error generation. For example, with the following error definition:

#[error_code]
pub enum ExternalError {
    Default,
    #[msg("Custom msg")]
    WithMsg,
}

and the following assertions:

assert_eq!(ExternalError::Default.to_string().as_str(), "Default");
assert_eq!(ExternalError::WithMsg.to_string().as_str(), "Custom msg");

the last assertion fails:

thread 'test_error_msg' (406948) panicked at programs/declare-program/tests/error.rs:19:5:
assertion `left == right` failed
  left: "WithMsg"
 right: "Custom msg"

Summary of changes

  • Add the missing error messages to the generated errors in declare_program!
  • Add error message generation tests and move all error tests to a dedicated file

@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

@acheroncrypto is attempting to deploy a commit to the OtterSec Team on Vercel.

A member of the Team first needs to authorize it.

@acheroncrypto acheroncrypto added fix Bug fix PR lang labels Jun 10, 2026
@jamie-osec jamie-osec merged commit f76b01a into otter-sec:master Jun 11, 2026
106 of 109 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix PR lang

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants