'Generalized helper method for managing specific API exception workflows'

def handle_exception(self, exc):

    if isinstance(exc, APIException):
        return self.make_error_response(exc.status_code, exc.detail)
    elif (isinstance(exc, Http404) or isinstance(exc, ObjectDoesNotExist)):
        return self.make_error_response(404, (exc.message or 'Not    found.'))
    elif isinstance(exc, ValidationError):
        return self.make_validation_error_response(exc)
    else:
        raise
