MCPcopy
hub / github.com/encode/django-rest-framework / ErrorDetail

Class ErrorDetail

rest_framework/exceptions.py:63–96  ·  view source on GitHub ↗

A string-like object that can additionally have a code.

Source from the content-addressed store, hash-verified

61
62
63class ErrorDetail(str):
64 """
65 A string-like object that can additionally have a code.
66 """
67 code = None
68
69 def __new__(cls, string, code=None):
70 self = super().__new__(cls, string)
71 self.code = code
72 return self
73
74 def __eq__(self, other):
75 result = super().__eq__(other)
76 if result is NotImplemented:
77 return NotImplemented
78 try:
79 return result and self.code == other.code
80 except AttributeError:
81 return result
82
83 def __ne__(self, other):
84 result = self.__eq__(other)
85 if result is NotImplemented:
86 return NotImplemented
87 return not result
88
89 def __repr__(self):
90 return 'ErrorDetail(string=%r, code=%r)' % (
91 str(self),
92 self.code,
93 )
94
95 def __hash__(self):
96 return hash(str(self))
97
98
99class APIException(Exception):

Callers 11

test_eqMethod · 0.90
test_neMethod · 0.90
test_reprMethod · 0.90
test_strMethod · 0.90
test_hashMethod · 0.90
errorsMethod · 0.90
errorsMethod · 0.90
get_error_detailFunction · 0.90
_get_error_detailsFunction · 0.85

Calls

no outgoing calls

Tested by 7

test_eqMethod · 0.72
test_neMethod · 0.72
test_reprMethod · 0.72
test_strMethod · 0.72
test_hashMethod · 0.72