def jb_exception_handler(exc, context):
    if isinstance(exc, exceptions.EntityNotFound):
        return ApiResponse.not_found(exc.error_code)
    if isinstance(exc, exceptions.BadDataException):
        return ApiResponse.bad_request(exc.error_code.dto_or_error_message, exc.error_code.error_code)
    if isinstance(exc, exceptions.JbAccessException):
        return ApiResponse.bad_request(exc.error_code.dto_or_error_message, exc.error_code.error_code)
    return exception_handler(exc, context)
def error_handler(exc, context):
    if isinstance(exc, MethodNotAllowed):
        return ApiResponse.bad_request('Request method error')
    if isinstance(exc, ControlledError):
        if isinstance(exc, NotFoundError):
            return ApiResponse.not_found(exc.error_code)
        if isinstance(exc, NotUniqueError):
            return ApiResponse.bad_request(exc.error_code)
    return exception_handler(exc, context)
Exemple #3
0
 def get(self, request: HttpRequest):
     return ApiResponse.not_found(errors.NOT_SUPPORTED)