diff options
| author | Danilo M. <danix@danix.xyz> | 2026-06-30 10:40:20 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-06-30 10:40:20 +0200 |
| commit | b357d987b3a149924dbc4eb584ab36529aaf195d (patch) | |
| tree | 9c7e045180f5bd057ed6c1a1f0c2715be07bf89e /firefly_cli/errors.py | |
| parent | a305c9a0c024e912548631e464e5f08ac24b1562 (diff) | |
| download | firefly-cli-b357d987b3a149924dbc4eb584ab36529aaf195d.tar.gz firefly-cli-b357d987b3a149924dbc4eb584ab36529aaf195d.zip | |
feat: error types
Diffstat (limited to 'firefly_cli/errors.py')
| -rw-r--r-- | firefly_cli/errors.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/firefly_cli/errors.py b/firefly_cli/errors.py new file mode 100644 index 0000000..0c0ec56 --- /dev/null +++ b/firefly_cli/errors.py @@ -0,0 +1,18 @@ +# Copyright (C) 2026 Danilo M. <danix@danix.xyz> GPL-2.0-only + +class FireflyError(Exception): + """Base for all firefly-cli errors.""" + +class ConfigError(FireflyError): + """Missing or invalid configuration.""" + +class ResolutionError(FireflyError): + """A name could not be resolved to a single id.""" + +class ApiError(FireflyError): + """Firefly returned a non-2xx response.""" + def __init__(self, status, body): + self.status = status + self.body = body + msg = body.get("message") if isinstance(body, dict) else body + super().__init__(f"API error {status}: {msg}") |
