'Exception middleware'

def process_exception(self, request, exception):

    if (not hasattr(request, '_desktop_app')):
        logging.debug('No    desktop_app    known    for    exception.')
        return None
    ret = None
    for middleware in self._get_middlewares(request._desktop_app, 'exception'):
        ret = middleware(request, exception)
        if ret:
            return ret
    return ret
