You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
suggestion: don't use std/assert in implementation code #4865
Using assertions from std/assert within implementation code in the codebase has a few drawbacks:
In cases where the user needs to error handle an API that uses assertions from std/assert, they need to import and use AssertionError.
While error messages provide the majority of the context behind an error, the constructor name does, too. I.e. RangeError. AssertionError is generic and doesn't add any context to the error.
It introduces an added dependency. In most cases, this doesn't matter. But for some, it does.
For these reasons, I suggest that we remove the use of assertions from std/assert within the implementation code in the Standard Library and instead use native error classes where possible. In cases where these native error classes do not fit, we can create and export custom error classes that extend Error. Doing so requires minimal code changes and can be more explicit than calling a generic assertion.
Activity