1 class JujuError(Exception):
2 def __init__(self
, *args
, **kwargs
):
6 self
.message
= str(args
[0])
7 if isinstance(args
[0], (list, tuple)):
10 self
.errors
= list(args
)
12 self
.errors
= [self
.message
]
13 super().__init
__(*args
, **kwargs
)
16 class JujuAPIError(JujuError
):
17 def __init__(self
, result
):
19 self
.message
= result
['error']
20 self
.error_code
= result
.get('error-code')
21 self
.response
= result
['response']
22 self
.request_id
= result
['request-id']
23 super().__init
__(self
.message
)
26 class JujuConnectionError(ConnectionError
, JujuError
):
30 class JujuAuthError(JujuConnectionError
):
34 class JujuRedirectException(Exception):
35 """Exception indicating that a redirection was requested"""
36 def __init__(self
, redirect_info
):
37 self
.redirect_info
= redirect_info
41 return self
.redirect_info
['ca-cert']
46 ('{value}:{port}'.format(**s
), self
.ca_cert
)
47 for servers
in self
.redirect_info
['servers']
48 for s
in servers
if s
['scope'] == 'public'