Improve coverage of multicloud-azure plugin
[multicloud/azure.git] / azure / multicloud_azure / pub / exceptions.py
1 # Copyright (c) 2018 Amdocs
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
13
14 class ClientException(Exception):
15
16     message = "ClientException"
17
18     def __init__(self, message=None):
19         self.message = message or self.message
20         super(ClientException, self).__init__(self.message)
21
22
23 class ServerException(Exception):
24
25     message = "ServerException"
26
27     def __init__(self, message=None, status_code="", content=""):
28         super(ServerException, self).__init__(message)
29         self.message = message or self.message
30         self.status_code = status_code
31         self.content = content
32
33
34 class RetriableConnectionFailure(Exception):
35     pass
36
37
38 class ConnectionError(ClientException):
39     message = "Cannot connect to API service."
40
41
42 class ConnectTimeout(ConnectionError, RetriableConnectionFailure):
43     message = "Timed out connecting to service."
44
45
46 class ConnectFailure(ConnectionError, RetriableConnectionFailure):
47     message = "Connection failure that may be retried."
48
49
50 class SSLError(ConnectionError):
51     message = "An SSL error occurred."
52
53
54 class UnknownConnectionError(ConnectionError):
55
56     def __init__(self, msg, original):
57         super(UnknownConnectionError, self).__init__(msg)
58         self.original = original
59
60
61 class NotFoundError(ServerException):
62     message = "Cannot find value"
63
64
65 class VimDriverAzureException(ServerException):
66     message = "Cannot find  vim driver"