gittip/aspen-python — pull request #288 by whit537 (2014-01-29 20:42:20+00:00)
Title: Take 2 on issue279

This is a second take on fixing #279. The approach in #280 is to switch error handling behavior at the algorithm layer based on `response.body`. In fact, our error simplate already varies its behavior based on `response.body`, and I think that's the layer at which switching on `response.body` belongs. The approach in this PR is to use any content negotiation that was performed during the original request when resolving the error simplate. So if a request comes in and is negotiated for `application/json`, then when we delegate to our error simplate (which as of #287 can only ever be a negotiated simplate; this PR depends on that one), we'll prefer an `application/json` content type, falling back to `text/plain`. We now ship a default error simplate that provides `text/html`, `application/json`, and `text/plain` sections. If a custom user error simplate doesn't provide a `text/plain` fallback then errors may result in `406 Not Acceptable`.