diff options
-rw-r--r-- | qvarn/__init__.py | 10 | ||||
-rw-r--r-- | qvarn/api_errors.py | 45 | ||||
-rw-r--r-- | without-tests | 2 |
3 files changed, 56 insertions, 1 deletions
diff --git a/qvarn/__init__.py b/qvarn/__init__.py index 6321b69..ceeb5f3 100644 --- a/qvarn/__init__.py +++ b/qvarn/__init__.py @@ -95,9 +95,17 @@ from .responses import ( unknown_search_field_response, ) +from .api_errors import ( + IdMismatch, + NoSuchResourceType, + NotJson, + TooManyResources, + TooManyResourceTypes, +) + from .router import Router from .file_router import FileRouter from .version_router import VersionRouter from .timestamp import get_current_timestamp -from .api import QvarnAPI, NoSuchResourceType +from .api import QvarnAPI diff --git a/qvarn/api_errors.py b/qvarn/api_errors.py new file mode 100644 index 0000000..368ddc5 --- /dev/null +++ b/qvarn/api_errors.py @@ -0,0 +1,45 @@ +# Copyright (C) 2017 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +class NoSuchResourceType(Exception): # pragma: no cover + + def __init__(self, path): + super().__init__('No resource type for path {}'.format(path)) + + +class TooManyResourceTypes(Exception): # pragma: no cover + + def __init__(self, path): + super().__init__('Too many resource types for path {}'.format(path)) + + +class TooManyResources(Exception): # pragma: no cover + + def __init__(self, resource_id): + super().__init__('Too many resources with id {}'.format(resource_id)) + + +class NotJson(Exception): # pragma: no cover + + def __init__(self, ct): + super().__init__('Was expecting application/json, not {}'.format(ct)) + + +class IdMismatch(Exception): # pragma: no cover + + def __init__(self, obj_id, id_from_path): + super().__init__( + 'Resource has id {} but path says {}'.format(obj_id, id_from_path)) diff --git a/without-tests b/without-tests index 636b24c..578e2d5 100644 --- a/without-tests +++ b/without-tests @@ -1,11 +1,13 @@ setup.py qvarn/__init__.py +qvarn/api_errors.py qvarn/backend.py qvarn/file_router.py qvarn/logging.py qvarn/responses.py qvarn/router.py qvarn/sql.py +qvarn/subresource_router.py qvarn/timestamp.py qvarn/version.py qvarn/version_router.py |