utils: simplify subclassing APIError (#86422)
By making err, http_status and log_error class variables with their default values.
This commit is contained in:
parent
3c30a76f3e
commit
45f6ee9e8d
|
@ -28,10 +28,14 @@ CALLBACK_NAME = getattr(settings, 'JSONRESPONSE_CALLBACK_NAME', 'callback')
|
|||
class APIError(RuntimeError):
|
||||
'''Exception to raise when there is a remote application or business logic error.'''
|
||||
|
||||
err = 1
|
||||
http_status = 200
|
||||
log_error = False
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.err = kwargs.pop('err', 1)
|
||||
self.log_error = kwargs.pop('log_error', False)
|
||||
self.http_status = kwargs.pop('http_status', 200)
|
||||
self.err = kwargs.pop('err', self.err)
|
||||
self.log_error = kwargs.pop('log_error', self.log_error)
|
||||
self.http_status = kwargs.pop('http_status', self.http_status)
|
||||
self.__dict__.update(kwargs)
|
||||
super().__init__(*args)
|
||||
|
||||
|
|
Loading…
Reference in New Issue