tastypie not returning NotFound exception error message
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Errors |
New
|
Medium
|
Unassigned |
Bug Description
If one uses the package-
new_version = request.
if not launchpad.
raise NotFound('%s version %s was not found in Launchpad.' % (src_package,
if not launchpad.
raise NotFound('%s version %s was not found in Launchpad.' % (src_package,
However, if you provide an invalid package version like in the following url the json content does not include the version not found in Launchpad message. However, you do receive a 404 response.
$ curl -v https:/
…
< HTTP/1.1 404 NOT FOUND
< Date: Thu, 20 Jun 2013 15:12:03 GMT
< Server: Apache/2.2.22 (Ubuntu)
< Vary: Cookie
< X-Daisy-
< X-Errors-
< Content-Length: 92
< Content-Type: application/json; charset=utf-8
< Strict-
<
{
"error_message": "Sorry, this request could not be processed. Please try again later."
* Connection #0 to host errors.ubuntu.com left intact
}%
summary: |
- tastypie not returning NotFound excpetion error message + tastypie not returning NotFound exception error message |
Changed in errors: | |
importance: | Undecided → Medium |
It will if you set settings.DEBUG = True, but we don't have that enabled in production. Tastypie does let you override the default error message (settings. TASTYPIE_ CANNED_ ERROR), but that's global.
I think the cleaner solution would be to override _handle_500 and checking to see if `exception` is an instance of NOT_FOUND_ EXCEPTIONS (see tastypie/ resources. py:277) . If it isn't, call the parent _handle_500. If it is, return self.error_ response( request, {'error_message': 'your error goes here'}, response_ class=HttpRespo nseNotFound) .