mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Add HTTPRequestError class
Currently, HTTP requests that respond with status not in the 2xx range raise RemoteRetrieveError. The exception includes no information about the response status. Add the 'HTTPRequestError' class which extends 'RemoteRequestError' with an attribute for the response status, and update the Dogtag RestClient to raise the new error. Part of: https://fedorahosted.org/freeipa/ticket/6260 Part of: https://fedorahosted.org/freeipa/ticket/3473 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
This commit is contained in:
parent
2a42a7e90e
commit
c5cbc8de89
@ -1406,6 +1406,16 @@ class OperationNotSupportedForPrincipalType(ExecutionError):
|
||||
'%(operation)s is not supported for %(principal_type)s principals')
|
||||
|
||||
|
||||
class HTTPRequestError(RemoteRetrieveError):
|
||||
"""
|
||||
**4035** Raised when an HTTP request fails. Includes the response
|
||||
status in the ``status`` attribute.
|
||||
"""
|
||||
|
||||
errno = 4035
|
||||
format = _('Request failed with status %(status)s: %(reason)s')
|
||||
|
||||
|
||||
class BuiltinError(ExecutionError):
|
||||
"""
|
||||
**4100** Base class for builtin execution errors (*4100 - 4199*).
|
||||
|
@ -2113,7 +2113,8 @@ class RestClient(Backend):
|
||||
)
|
||||
if status < 200 or status >= 300:
|
||||
explanation = self._parse_dogtag_error(resp_body) or ''
|
||||
raise errors.RemoteRetrieveError(
|
||||
raise errors.HTTPRequestError(
|
||||
status=status,
|
||||
reason=_('Non-2xx response from CA REST API: %(status)d. %(explanation)s')
|
||||
% {'status': status, 'explanation': explanation}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user