The majority of JSON errors I return are 200-ok messages with an internal 
error message.

I have a current need to "upgrade" an existing response/renderer into an 
error, as it's being consumed by a 3rd party javascript plugin that we 
don't have as much control in:

This seems to work, but I'm wondering if anyone sees an issue with it:

     class MyViews(object):
          @view_config(renderer='json', 
route_name='api-internal:autocomplete:username')
          def autocomplete_username(self):
               rval = []
               try:
                    pass
               except:
                     self.request.response.status_code = 500
                     rval = ['!Error',]
               return rval

I'd like to avoid generating a new response in the "except" block; we have 
some various logging/metrics tied into the render event and it's going to 
look a bit ugly/redundant to maintain parity with that across this section 
of the API.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to