Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rest_framework/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def __init__(self, detail=None, code=None):
code = self.default_code

self.detail = _get_error_details(detail, code)
super().__init__(self.detail)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not passing down the code to this one? This changes the representation of the exception in the REPL and make it quite verbose:

Before

>>> APIException("Invalid input", 400)
APIException('Invalid input', 400)

After

>>> APIException("Invalid input", 400)
APIException(ErrorDetail(string='Invalid input', code=400))


def __str__(self):
return str(self.detail)
Expand Down Expand Up @@ -159,6 +160,7 @@ def __init__(self, detail=None, code=None):
detail = [detail]

self.detail = _get_error_details(detail, code)
super().__init__(self.detail, code)
Comment thread
RinZ27 marked this conversation as resolved.

@browniebroke browniebroke Jul 25, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment on verbosity.

Before

>>> ValidationError("Invalid input", 400)
ValidationError('Invalid input', 400)

After

>>> ValidationError("Invalid input", 400)
ValidationError([ErrorDetail(string='Invalid input', code=400)])



class ParseError(APIException):
Expand Down