Add python shareddatalayer API and public exceptions.
[ric-plt/sdlpy.git] / sdl / exceptions.py
1 # Copyright (c) 2019 AT&T Intellectual Property.
2 # Copyright (c) 2018-2019 Nokia.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 "Exceptions raised by the shareddatalayer."
17
18 class SdlTypeError(TypeError):
19     """
20     Exception for passing a function argument of wrong type.
21     It is likely that the same request will fail repeatedly. It is advised to investigate the exact
22     reason for the failure from the logs.
23     """
24     pass
25
26 class SdlException(Exception):
27     """Base exception class for shareddatalayer exceptions."""
28     pass
29
30 class NotConnected(SdlException):
31     """
32     Exception for not being connected to the database backend.
33     Shareddatalayer is not connected to the backend data storage and therefore could not deliver the
34     request to the backend data storage. Data in the backend data storage has not been altered.
35     Client is advised to try the operation again later.
36     """
37     pass
38
39 class BackendError(SdlException):
40     """
41     Exception for request processing failure.
42     In case of a write type request, data in the backend data storage may or may not have been
43     altered. Client is advised to try the operation again later.
44     """
45     pass
46
47 class RejectedByBackend(SdlException):
48     """
49     Exception for shareddatalayer rejecting the request.
50     Backend data storage rejected the request. In case of a write type request, data in the backend
51     data storage may or may not have been altered. It is likely that the same request will fail
52     repeatedly. It is advised to investigate the exact reason for the failure from the logs.
53     """
54     pass