Skip to content

Avoid raising plain exception#728

Open
EpicWink wants to merge 3 commits intopython-attrs:mainfrom
EpicWink:literal-exception
Open

Avoid raising plain exception#728
EpicWink wants to merge 3 commits intopython-attrs:mainfrom
EpicWink:literal-exception

Conversation

@EpicWink
Copy link
Contributor

Raise a new CattrsError instead of built-in Exception, and make all other exceptions inherit from this.

This makes it more reliable to catch validation issues due to invalid literal or date-time values when structuring (instead of having to parse the exception message when catching Exception).

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 26, 2026

Merging this PR will not alter performance

✅ 54 untouched benchmarks


Comparing EpicWink:literal-exception (7c8f9b5) with main (573915b)

Open in CodSpeed

@Tinche
Copy link
Member

Tinche commented Feb 26, 2026

I'm good with this; I was somewhat lazy in the past about it. Backwards compatibility should be fine, right?

@EpicWink
Copy link
Contributor Author

Backwards compatibility should be fine, right?

@Tinche yes. Only possible breakages would be from some inane strict equality checks on Exception

@Tinche Tinche requested review from Tinche and hynek March 1, 2026 10:11
@EpicWink EpicWink changed the title Avoid raising plan exception Avoid raising plain exception Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants