mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 11:04:02 +03:00
Refactor short names in exceptions (#8585)
This commit is contained in:
parent
224168a28f
commit
fd8adb32ce
|
@ -1,7 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Handled exceptions raised by REST framework.
|
Handled exceptions raised by REST framework.
|
||||||
|
|
||||||
In addition Django's built in 403 and 404 exceptions are handled.
|
In addition, Django's built in 403 and 404 exceptions are handled.
|
||||||
(`django.http.Http404` and `django.core.exceptions.PermissionDenied`)
|
(`django.http.Http404` and `django.core.exceptions.PermissionDenied`)
|
||||||
"""
|
"""
|
||||||
import math
|
import math
|
||||||
|
@ -72,19 +72,19 @@ class ErrorDetail(str):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
r = super().__eq__(other)
|
result = super().__eq__(other)
|
||||||
if r is NotImplemented:
|
if result is NotImplemented:
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
try:
|
try:
|
||||||
return r and self.code == other.code
|
return result and self.code == other.code
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return r
|
return result
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
r = self.__eq__(other)
|
result = self.__eq__(other)
|
||||||
if r is NotImplemented:
|
if result is NotImplemented:
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
return not r
|
return not result
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'ErrorDetail(string=%r, code=%r)' % (
|
return 'ErrorDetail(string=%r, code=%r)' % (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user