示例#1
0
 def process_response(self, req, resp, resource):
     """
         Post-processing of the response (after routing).
     """
     if resp.status in DAOTransaction.__OK_STATUSES:
         AbstractDAO.commit()
     else:
         assert resp.status not in DAOTransaction.__OK_STATUSES
         AbstractDAO.rollback()
示例#2
0
    def handle_exception(ex, req, resp, params):
        """
            Rolls back the current transaction if an error has occurred
        """
        try:
            AbstractDAO.rollback()
        except Exception as _ex:
            ex = _ex

        FalconExceptions.__LOGGER.error("Error: %s", ex, exc_info=1)

        if isinstance(ex, falcon.HTTPError):
            raise HttpError(ex.status, ex.status, ex.title)
        elif isinstance(ex, AppException):
            #get the correct http status
            http_status = FalconExceptions.BB_EXCEPTION_TO_FALCON[ex.internal_exception_status]
            raise HttpError(http_status, ex.internal_exception_status.value, ex.message)
        else:
            raise HttpError(falcon.status_codes.HTTP_500,
                            InternalExceptionStatus.SERVER_ERROR.value,
                            str(ex))