Django rest framework 在DRF中的异常处理程序中获取原始异常消息(从中引发)

Django rest framework 在DRF中的异常处理程序中获取原始异常消息(从中引发),django-rest-framework,Django Rest Framework,例如,我有以下验证器: @deconstructible class TimeZoneValidator: """ Validates whether input string is valid timezone name or not. """ def __call__(self, value): try: zoneinfo.ZoneInfo(value)

例如,我有以下验证器:

@deconstructible
class TimeZoneValidator:
    """
    Validates whether input string is valid timezone name or not.
    """
    def __call__(self, value):
        try:
            zoneinfo.ZoneInfo(value)
        except zoneinfo.ZoneInfoNotFoundError as err:
            raise exceptions.ValidationError(
                *messages.user_2,
            ) from err
因此,此处的
ValidationError
应包含第一条
zoneinfo.zoneinfo-FoundError
错误消息,该消息可能位于
\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu

问题是–如果我有这样的自定义异常处理程序:

def custom_exception_handler(exc, context):
    """
    Base function for handling exceptions in DRF.
    """
    response = exception_handler(exc, context)

    return response
我如何才能在此处获得此原始
zoneinfo.zoneinfo-NotFoundError
错误消息