Comment 1 for bug 980033

Revision history for this message
Guilherme Salgado (salgado) wrote :

I wanted to give this one a go (as it's tagged as low-hanging-fruit and so I thought it'd be a good choice for me to get started) and after playing with quantum a bit I think a fix for this would have to go in Resource.__call__(). I'm thinking that the most appropriate thing to do would be to have a separate except block there catching everything that's not a webob.exc.HTTPException, and treat those as internal errors, logging them but not including the original exception in the Fault() object returned. Something like:

        try:
            action_result = self.dispatch(request, action, args)
        except webob.exc.HTTPException as ex:
            LOG.info(_("HTTP exception thrown: %s"), unicode(ex))
            action_result = Fault(ex,
                                  self._xmlns,
                                  self._fault_body_function)
        except Exception as exc:
            LOG.exception("Internal error: %s", unicode(exc))
            action_result = Fault(exception.Error("Internal error"),
                                  self._xmlns,
                                  self._fault_body_function)

That way the error messages of "expected" exceptions (i.e. those wrapped in an HTTPException by @common.APIFaultWrapper) will be sent to the client but everything else will be sent to clients with a generic "internal error" message.

Does this sound reasonable?