diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-11-18 20:07:02 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-11-18 20:24:34 +0100 |
commit | b0c6bce3a8df1ea730a535cd2e3dd8be7ff4422e (patch) | |
tree | c0e0d703f3a0c74ee1b07a63c8718d56b160df0b /ick2/controllerapi.py | |
parent | 18753714a35b6c8e5af4b6076973f490a1ba2097 (diff) | |
download | ick2-b0c6bce3a8df1ea730a535cd2e3dd8be7ff4422e.tar.gz |
Refactor: move API specific exceptions into a separate module
Diffstat (limited to 'ick2/controllerapi.py')
-rw-r--r-- | ick2/controllerapi.py | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/ick2/controllerapi.py b/ick2/controllerapi.py index 6d00b9e..6cbf389 100644 --- a/ick2/controllerapi.py +++ b/ick2/controllerapi.py @@ -211,7 +211,7 @@ class ResourceApiBase(APIbase): self._type_name, self.get_resource_name(body), body) def get_resource_name(self, resource): # pragma: no cover - raise NotImplementedError + raise NotImplementedError() def update(self, body, name): return self._state.update_resource(self._type_name, name, body) @@ -238,10 +238,10 @@ class BuildsAPI(ResourceApiBase): # pragma: no cover return resource['build'] def create(self, body): # pragma: no cover - raise MethodNotAllowed('Creating builds directly is not allowed') + raise ick2.MethodNotAllowed('Creating builds directly is not allowed') def update(self, body, name): # pragma: no cover - raise MethodNotAllowed('Updating builds directly is not allowed') + raise ick2.MethodNotAllowed('Updating builds directly is not allowed') def list(self): result = super().list() @@ -260,10 +260,10 @@ class LogAPI(ResourceApiBase): # pragma: no cover return resource['log'] def create(self, body): # pragma: no cover - raise MethodNotAllowed('Creating builds directly is not allowed') + raise ick2.MethodNotAllowed('Creating builds directly is not allowed') def update(self, body, name): # pragma: no cover - raise MethodNotAllowed('Updating builds directly is not allowed') + raise ick2.MethodNotAllowed('Updating builds directly is not allowed') def show(self, name): log = self._state.get_resource('log', str(name)) @@ -421,7 +421,7 @@ class WorkAPI(APIbase): def update_work(self, update): if 'worker' not in update: # pragma: no cover - raise BadUpdate('no worker specified') + raise ick2.BadUpdate('no worker specified') worker_state = self._get_worker(update['worker']) doing = worker_state.get('doing', {}) @@ -474,9 +474,9 @@ class WorkAPI(APIbase): must_match = ['worker', 'project', 'pipeline', 'build_id'] for name in must_match: if name not in update: - raise BadUpdate('{} not specified'.format(name)) + raise ick2.BadUpdate('{} not specified'.format(name)) if doing.get(name) != update[name]: - raise BadUpdate( + raise ick2.BadUpdate( '{} differs from current work: {} vs {}'.format( name, doing.get(name), update[name])) @@ -542,15 +542,3 @@ class WorkAPI(APIbase): def delete(self, *args, **kwargs): # pragma: no cover pass - - -class BadUpdate(Exception): # pragma: no cover - - def __init__(self, how): - super().__init__('Work update is BAD: {}'.format(how)) - - -class MethodNotAllowed(Exception): # pragma: no cover - - def __init__(self, wat): - super().__init__(wat) |