From: Dustin Walde Date: Sat, 23 Sep 2023 04:05:45 +0000 (-0700) Subject: Rename base error class X-Git-Url: https://git.walde.dev/?a=commitdiff_plain;h=15ff770dc41899955e151328429a88addacd75ee;p=punch Rename base error class --- diff --git a/src/errors.py b/src/errors.py index 87918e4..25dd89b 100644 --- a/src/errors.py +++ b/src/errors.py @@ -4,23 +4,23 @@ ERR_UNKNOWN_COMMAND = 3 ERR_INVALID_ARG = 4 ERR_ILLEGAL_STATE = 127 -class TimeTrackError(Exception): +class PunchCardError(Exception): @property def exit_code(self) -> int: return NotImplemented -class IllegalStateError(TimeTrackError): +class IllegalStateError(PunchCardError): def exit_code(self) -> int: return ERR_ILLEGAL_STATE -class InvalidArgumentError(TimeTrackError): +class InvalidArgumentError(PunchCardError): def exit_code(self) -> int: return ERR_INVALID_ARG -class MissingArgumentError(TimeTrackError): +class MissingArgumentError(PunchCardError): def __init__(self, *args: object) -> None: super().__init__( f"Missing argument: {args[0]}", @@ -30,7 +30,7 @@ class MissingArgumentError(TimeTrackError): return ERR_MISSING_ARG -class NoSuchCategoryError(TimeTrackError): +class NoSuchCategoryError(PunchCardError): def __init__(self, category: str) -> None: super().__init__(f"No such category: {category}") @@ -38,7 +38,7 @@ class NoSuchCategoryError(TimeTrackError): return ERR_NO_SUCH_CATEGORY -class UnknownCommandError(TimeTrackError): +class UnknownCommandError(PunchCardError): def __init__(self, *args: object) -> None: super().__init__( f"Unknown subcommand: {args[0]}", diff --git a/src/punch.py b/src/punch.py index ada20ae..c1a8e23 100644 --- a/src/punch.py +++ b/src/punch.py @@ -12,7 +12,7 @@ from errors import ( IllegalStateError, MissingArgumentError, NoSuchCategoryError, - TimeTrackError, + PunchCardError, UnknownCommandError, ) from puncher import Puncher @@ -200,7 +200,7 @@ def main(args): if __name__ == "__main__": try: main(sys.argv) - except TimeTrackError as e: + except PunchCardError as e: command = None if len(sys.argv) > 1: command = sys.argv[1]