Skip to content

Release v0.15.0

Latest
Compare
Choose a tag to compare
@github-actions github-actions released this 09 Jun 07:48
· 4 commits to main since this release

Added

  • add support for python 3.13
  • add support for django 5.2
  • add support for DRF 3.16

Changed (backward-incompatible)

  • Unhandled exceptions now return a generic error message by default. This avoids unintentionally leaking
    sensitive data included in the exception message. To revert to the old behavior or change the default error
    message:
    • create a custom exception handler class
      from rest_framework.exceptions import APIException
      from drf_standardized_errors.handler import ExceptionHandler
      
      class MyExceptionHandler(ExceptionHandler):
          def convert_unhandled_exceptions(self, exc: Exception) -> APIException:
              if not isinstance(exc, APIException):
                  # `return APIException(detail=str(exc))` restores the old behavior 
                  return APIException(detail="New error message")
              else:
                  return exc
    • Then, update the settings to point to your exception handler class
      DRF_STANDARDIZED_ERRORS = {
          # ...
          "EXCEPTION_HANDLER_CLASS": "path.to.MyExceptionHandler"
      }
  • set minimum version of drf-spectacular to 0.27.1
  • drf_standardized_errors.types.ErrorType is now the following type hint
    from typing import Literal
    ErrorType = Literal["validation_error", "client_error", "server_error"]
    ErrorType was previously an enum. If you referenced its members in your code, make sure to replace their
    use cases with the newly added constants:
    from drf_standardized_errors.types import VALIDATION_ERROR, CLIENT_ERROR, SERVER_ERROR
    ErrorType.VALIDATION_ERROR --> VALIDATION_ERROR
    ErrorType.CLIENT_ERROR --> CLIENT_ERROR
    ErrorType.SERVER_ERROR --> SERVER_ERROR