Page MenuHomePhabricator

Should the Assert library's exceptions extend AssertionError instead?
Open, Needs TriagePublic

Description

As noted in T226266#5432422: given that AssertionException extends Exception, it could happen that they get caught inside of a try {} catch (Exception) block, thus defeating the purpose of assertions. AssertionErrors aren't that easy to catch (you'd have to catch either the class itself, or Error), and seem like a best fit for this use case.
Is there a specific reason why the library is not using it?

Event Timeline

Daimona created this task.Thu, Aug 22, 6:45 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptThu, Aug 22, 6:45 PM