diff options
author | Devaev Maxim <[email protected]> | 2019-12-09 02:26:48 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-12-09 02:26:48 +0300 |
commit | 3048fc79233f1ece909dee0f100e72a2f3f5a639 (patch) | |
tree | 834e0ab68541ecf0f58a4100f90ca0836b6f9bf5 /kvmd/apps | |
parent | dd52a85cf6c21c5a7743acad152d8378f1ae0ef4 (diff) |
very common exceptions
Diffstat (limited to 'kvmd/apps')
-rw-r--r-- | kvmd/apps/kvmd/server.py | 15 | ||||
-rw-r--r-- | kvmd/apps/kvmd/wol.py | 4 |
2 files changed, 8 insertions, 11 deletions
diff --git a/kvmd/apps/kvmd/server.py b/kvmd/apps/kvmd/server.py index cd687918..70d02582 100644 --- a/kvmd/apps/kvmd/server.py +++ b/kvmd/apps/kvmd/server.py @@ -42,16 +42,13 @@ import setproctitle from ...logging import get_logger +from ...errors import OperationError +from ...errors import IsBusyError + from ...plugins import BasePlugin from ...plugins.hid import BaseHid - -from ...plugins.atx import AtxOperationError -from ...plugins.atx import AtxIsBusyError from ...plugins.atx import BaseAtx - -from ...plugins.msd import MsdOperationError -from ...plugins.msd import MsdIsBusyError from ...plugins.msd import BaseMsd from ...validators import ValidatorError @@ -71,8 +68,6 @@ from .auth import AuthManager from .info import InfoManager from .logreader import LogReader from .streamer import Streamer - -from .wol import WolDisabledError from .wol import WakeOnLan from .http import UnauthorizedError @@ -337,9 +332,9 @@ class KvmdServer(HttpServer): # pylint: disable=too-many-arguments,too-many-ins return (await exposed.handler(request)) - except (AtxIsBusyError, MsdIsBusyError) as err: + except IsBusyError as err: return make_json_exception(err, 409) - except (ValidatorError, AtxOperationError, MsdOperationError, WolDisabledError) as err: + except (ValidatorError, OperationError) as err: return make_json_exception(err, 400) except UnauthorizedError as err: return make_json_exception(err, 401) diff --git a/kvmd/apps/kvmd/wol.py b/kvmd/apps/kvmd/wol.py index 40c40d1d..ea62aea1 100644 --- a/kvmd/apps/kvmd/wol.py +++ b/kvmd/apps/kvmd/wol.py @@ -27,11 +27,13 @@ from typing import Optional from ...logging import get_logger +from ...errors import OperationError + from ... import aiotools # ===== -class WolDisabledError(Exception): +class WolDisabledError(OperationError): def __init__(self) -> None: super().__init__("WoL is disabled") |