]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/nfs/exception.py
import ceph 16.2.7
[ceph.git] / ceph / src / pybind / mgr / nfs / exception.py
1 import errno
2 from typing import Optional
3
4
5 class NFSException(Exception):
6 def __init__(self, err_msg: str, errno: int = -1) -> None:
7 super(NFSException, self).__init__(errno, err_msg)
8 self.errno = errno
9 self.err_msg = err_msg
10
11 def __str__(self) -> str:
12 return self.err_msg
13
14
15 class NFSInvalidOperation(NFSException):
16 def __init__(self, err_msg: str) -> None:
17 super(NFSInvalidOperation, self).__init__(err_msg, -errno.EINVAL)
18
19
20 class NFSObjectNotFound(NFSException):
21 def __init__(self, err_msg: str) -> None:
22 super(NFSObjectNotFound, self).__init__(err_msg, -errno.ENOENT)
23
24
25 class FSNotFound(NFSObjectNotFound):
26 def __init__(self, fs_name: Optional[str]) -> None:
27 super(FSNotFound, self).__init__(f'filesystem {fs_name} not found')
28
29
30 class ClusterNotFound(NFSObjectNotFound):
31 def __init__(self) -> None:
32 super(ClusterNotFound, self).__init__('cluster does not exist')