summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-cli/src/meshbay_cli/errors.py
blob: 319645e97fb87eabcd5ab54878ee11d9150774e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""
Every way a run can end badly, as an exit code a script can act on.

The library raises `CliError` with one of these codes; only `__main__` turns it
into a message and an exit status.
"""

USAGE = 1
AUTH = 2           # sign-in refused, no session and no passphrase, locked out
NOT_FOUND = 3      # group, path, or a pattern that matches nothing
PARTIAL = 4        # some items failed
NODE = 5           # node unreachable, or it refused the connection
NODE_KEY = 6       # a node's key changed since it was pinned
VERSION = 7        # this client, or the protocol, is too old or too new
REFUSED = 8        # refused before anything was sent: a name taken or not accepted,
                   # a folder read-only or unavailable
INTERRUPTED = 130


class CliError(Exception):
    def __init__(self, code: int, message: str):
        super().__init__(message)
        self.code = code
        self.message = message