]>
Commit | Line | Data |
---|---|---|
b3b6e05e | 1 | import errno |
a4b75251 | 2 | from typing import Optional |
b3b6e05e TL |
3 | |
4 | ||
5 | class NFSException(Exception): | |
a4b75251 | 6 | def __init__(self, err_msg: str, errno: int = -1) -> None: |
b3b6e05e TL |
7 | super(NFSException, self).__init__(errno, err_msg) |
8 | self.errno = errno | |
9 | self.err_msg = err_msg | |
10 | ||
a4b75251 | 11 | def __str__(self) -> str: |
b3b6e05e TL |
12 | return self.err_msg |
13 | ||
14 | ||
15 | class NFSInvalidOperation(NFSException): | |
a4b75251 TL |
16 | def __init__(self, err_msg: str) -> None: |
17 | super(NFSInvalidOperation, self).__init__(err_msg, -errno.EINVAL) | |
b3b6e05e TL |
18 | |
19 | ||
20 | class NFSObjectNotFound(NFSException): | |
a4b75251 TL |
21 | def __init__(self, err_msg: str) -> None: |
22 | super(NFSObjectNotFound, self).__init__(err_msg, -errno.ENOENT) | |
b3b6e05e TL |
23 | |
24 | ||
25 | class FSNotFound(NFSObjectNotFound): | |
a4b75251 | 26 | def __init__(self, fs_name: Optional[str]) -> None: |
b3b6e05e TL |
27 | super(FSNotFound, self).__init__(f'filesystem {fs_name} not found') |
28 | ||
29 | ||
30 | class ClusterNotFound(NFSObjectNotFound): | |
a4b75251 | 31 | def __init__(self) -> None: |
b3b6e05e | 32 | super(ClusterNotFound, self).__init__('cluster does not exist') |