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

Idea: use panic codes instead of custom errors #4867

Closed
Amxx opened this issue Feb 1, 2024 · 1 comment · Fixed by #4872
Closed

Idea: use panic codes instead of custom errors #4867

Amxx opened this issue Feb 1, 2024 · 1 comment · Fixed by #4872
Labels

Comments

@Amxx
Copy link
Collaborator

Amxx commented Feb 1, 2024

There are some cases where we use custom error, but Panic codes may be more relevant/standard.

Some example (not exaustive):

  • In Math.mulDiv, if the prod1 > denominator, we should probably Panic with 0x11 (ARITHMETIC_UNDER_OR_OVERFLOW) if denominator > 0 or 0x12 (DIVISION_BY_ZERO) if denominator == 0 instead of using MathOverflowedMulDiv

  • In DoubleEndedQueue, we should probably replace

    • QueueEmpty → panic 0x31 (POP_ON_EMPTY_ARRAY)
    • QueueFull → panic 0x32 (ARRAY_ACCESS_OUT_OF_BOUNDS)
    • QueueOutOfBounds → panic 0x41 (TOO_MUCH_MEMORY_ALLOCATED)
@Amxx Amxx added the idea label Feb 1, 2024
@Amxx
Copy link
Collaborator Author

Amxx commented Feb 1, 2024

I'm not sure If we did commit to custom error stability. Would this be considered a breaking change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant