From bf53e08f0f6c87ef9c53781142f8c437c5975b53 Mon Sep 17 00:00:00 2001 From: kieffer julien Date: Fri, 28 Aug 2020 12:03:06 +0200 Subject: [PATCH] ErrorDetails implementation --- rest_framework/exceptions.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py index 71419b54a..cb62787be 100644 --- a/rest_framework/exceptions.py +++ b/rest_framework/exceptions.py @@ -91,13 +91,18 @@ class ErrorDetail(str): return not self.__eq__(other) def __repr__(self): - base = 'ErrorDetail(string=%r, code=%r' % ( + if self.params: + return 'ErrorDetail(string=%r, code=%r, params=%s)' % ( + str(self), + self.code, + self.params + ) + + return 'ErrorDetail(string=%r, code=%r)' % ( str(self), self.code, ) - return base + ', params=%r)' % self.params if self.params else base + ')' - def __hash__(self): return hash(str(self))