Page MenuHomePhabricator

errors: make exit codes class variables instead
ClosedPublic

Authored by martinvonz on May 20 2021, 11:21 AM.

Details

Summary

Kyle pointed out to me that we can simply make the exit codes class
variables. Python provides some magic for making them accessible as
instance variables.

This also makes it easier to let subclasses of existing errors
override the exit codes by letting them simply define their own values
as class variables. That means that there's no need to pass them into
the superclass's constructor arguments, so the superclass doesn't need
to expose the them as arguments. (Making a subclass set a different
exit code for a subclass of StorageError was actually the goal with
my recent series.)

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

martinvonz created this revision.May 20 2021, 11:21 AM
This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.