blob: f97ccdf8a6dfd7ec8c820c7e16451d8458c92302 [file] [log] [blame]
Mitja Nikolause9208082018-07-30 14:22:09 +02001"""Response descriptions for HTTP responses."""
Mitja Nikolaus9c3b29e2018-08-22 11:17:50 +02002from typing import Tuple, Type
3
4from rest_framework.exceptions import APIException
Mitja Nikolause9208082018-07-30 14:22:09 +02005
6
Mitja Nikolaus9c3b29e2018-08-22 11:17:50 +02007def default_desc(exception: Type[APIException]) -> Tuple[int, str]:
Mitja Nikolause9208082018-07-30 14:22:09 +02008 """Get the default response description for an exception.
9
10 Args:
Mitja Nikolaus9c3b29e2018-08-22 11:17:50 +020011 exception:
Mitja Nikolause9208082018-07-30 14:22:09 +020012 A subclass of APIException for which the response description
13 should be returned.
14
15 Returns:
Mitja Nikolaus9c3b29e2018-08-22 11:17:50 +020016 A tuple containing the matching status code and default description
17 for the exception.
Mitja Nikolause9208082018-07-30 14:22:09 +020018
19 """
20 return exception.status_code, str(exception.default_detail)