On Mar 1, 2011, at 8:28 AM, Lorin Rivers wrote:
> 
> @jonathan: Yes, a more detailed error messages than "no json" would be 
> awesome.

generic.json now says:

{{
###
# response._vars contains the dictionary returned by the controller action
###
try:
   from gluon.serializers import json
   response.write(json(response._vars),escape=False)
   response.headers['Content-Type']='text/json'
except:
   raise HTTP(405,'no json')
}}


I suggest this instead:

{{
###
# response._vars contains the dictionary returned by the controller action
###
try:
        from gluon.serializers import json
        response.write(json(response._vars), escape=False)
        response.headers['Content-Type'] = 'application/json'
except (TypeError, ValueError):
        raise HTTP(405, 'JSON serialization error')
except ImportError:
        raise HTTP(405, 'JSON not available')
except:
        raise HTTP(405, 'JSON error')
}}

Reply via email to