On Tuesday, September 20, 2016 at 9:20:48 AM UTC-7, Ty oc wrote: > > Well also now I got it (still not per app)... >
Well, the book says routes_onerror can specify a global mapping, an app mapping, an error code mapping, or app+err. <URL:http://web2py.com/books/default/chapter/29/04/the-core#Routes-on-error> Just above that, in the tail of the pattern-based router description, it talks about how to have the base routes.py direct to an app routes.py for handling the other URLs of a specific application. /dps > but the problem Im having is that I want to return a *json*, but Im > getting the full HTML response with a body and all that. > > If I use > > error_handler = dict(application='backend', > controller='error', > function='report') > > > Nothing changes. So I have setup > > routes_onerror = [ > ('init/400', '/backend/default/index'), > ('init/*', '/backend/default/index'), > ('*/404', '/backend/default/index'), > ('*/*', '/backend/error/report') > ] > > > > I have as response this HTML instead of the json > > > <html><head><link rel="alternate stylesheet" type="text/css" > href="resource://gre-resources/plaintext.css" ></head><body > data-pinterest-extension-installed="ff1.37.9"><pre>{&#x27;message&#x27;: > > &#x27;Error interno&#x27;}</pre></body></html> > > El martes, 20 de septiembre de 2016, 10:22:34 (UTC-5), Ty oc escribió: >> >> I mean, we have other web2py apps there, I dont want to modify the >> default behaviour of the other ones, only this "backend" app. >> >> El martes, 20 de septiembre de 2016, 10:06:10 (UTC-5), Ty oc escribió: >>> >>> I thought it was a per app configuration. >>> >>> El lunes, 19 de septiembre de 2016, 17:51:28 (UTC-5), Anthony escribió: >>>> >>>> routes.py goes in the root /web2py folder. Be sure to restart the >>>> server or reload routes (via admin). Also, make sure you don't actually >>>> have an error somewhere in your error handling app. >>>> >>>> On Monday, September 19, 2016 at 5:02:11 PM UTC-4, Ty oc wrote: >>>>> >>>>> Where exactly I need to put this file? >>>>> >>>>> I have tried >>>>> >>>>> error_message = '<html><body><h1>%s-------</h1></body></html>' >>>>> error_message_ticket = '''<html><body><h1>Internal error</h1> >>>>> Ticket issued: <a href="/admin/default/ticket/%(ticket)s" >>>>> target="_blank">%(ticket)s</a>------</body></html>''' >>>>> >>>>> routes_onerror = [ >>>>> ('init/400', '/backend/default/index'), >>>>> ('init/*', '/backend/default/index'), >>>>> ('*/404', '/backend/default/index'), >>>>> ('*/*', '/backend/error/report') >>>>> ] >>>>> >>>>> >>>>> >>>>> error_handler = dict(application='backend', >>>>> controller='error', >>>>> function='report') >>>>> >>>>> >>>>> >>>>> Still no correct message displayed if I cause a 500 server error. >>>>> Where do I activate it? >>>>> >>>>> I mean, even debugging passes over the redirector inside web2py and >>>>> see nothing on those variables causing normal behaviour on the branch on >>>>> rewrite.py >>>>> >>>>> if status >= 399 and THREAD_LOCAL.routes.routes_onerror: >>>>> >>>>> >>>>> >>>>> so.... >>>>> >>>>> >>>>> El martes, 6 de septiembre de 2016, 11:17:58 (UTC-5), Anthony escribió: >>>>>> >>>>>> http://web2py.com/books/default/chapter/29/04/the-core#Routes-on-error >>>>>> >>>>>> Anthony >>>>>> >>>>>> On Tuesday, September 6, 2016 at 10:43:19 AM UTC-4, Ty oc wrote: >>>>>>> >>>>>>> Still I need to log the ticket issue so we know what is happening >>>>>>> (we will be watching for errors to show on the admin webapp), but we >>>>>>> dont >>>>>>> want the error to be like the HTML that is always show to the user. >>>>>>> >>>>>>> I want to return a one of the following depending on where Im >>>>>>> returning it (a page in the web app or a request of a service) >>>>>>> >>>>>>> >>>>>>> - for the service >>>>>>> - {"error":"see ticket xyz"} >>>>>>> - for the HTML webpage >>>>>>> - General error, return home "here". >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

