Inconsistance throwing behavior on String and Regex's xxMatch

The core regex operations can throw, because things like custom regex consumers can throw their own custom errors. Regex's hosted API will faithfully surface these failure reasons rather than squash them all into a single notion of failure via nil. This is useful for libraries and more advanced use cases.

The common case is to not care about how something failed to match. The API on string are collection algorithms that will coalesce all failure reasons into nil, meaning it failed. This is more convenient as the caller of these higher level operations care about match-or-not. If these threw, then all the call sites would be annotated with extra try? ceremony for little benefit.

5 Likes