On Thursday, December 14, 2017 at 10:36:08 PM UTC-5, Brendan Barnwell wrote: > > On Thursday, December 14, 2017 at 4:10:40 AM UTC-8, Anthony wrote: >> >> Could be a little complicated. The relevant code is in gluon.restricted >> -- see >> https://github.com/web2py/web2py/blob/4f51647b2f5bd68887ddd9fe139c6bbc0fa885d4/gluon/restricted.py#L115 >> . >> >> > That is unfortunate. Would be nice to have this in a more modularized > fashion, but I'll see if I can make it work. >
Feel free to make a pull request. Note, depending on your needs, some other options might be: - Capture and store the tracebacks yourself. You could create a db.error table and then use code like: try: [some code] except: db.error.insert(exception=traceback.format_exc()) - Create a custom error handler via routes_onerror (see http://web2py.com/books/default/chapter/29/04/the-core#Routes-on-error). That will allow you to handle errors however you like while still generating error tickets to be viewed in admin. Note, it will still do a database rollback before passing control to your error handler, and although there is no HTTP redirect, it will generate a new web2py environment and run the models again. > >> You could create a RestrictedError (don't raise it, though, as that will >> trigger web2py's error processing). Calling the .log() method on that error >> object should then generate the ticket. Note, you'll be responsible for >> specifying the proper values for the "layer", "code", and "environment" >> arguments to RestrictedError() (for "environment", current.globalenv should >> be the proper value). >> >> > Cool, thanks. But what about "code"? It looks like RestrictedError is > mainly called from the restricted() function, and everywhere I can see that > calls restricted() has a bunch of complicated logic in the same function to > determine what to pass for its "ccode" argument. Is there a way to access > this information from within controller code? > I don't think so. For errors in models, the code would be the model file. For controllers, the code would be the controller file with an extra line added at the bottom to run the function that was called. And for views, the code would be the parsed view code. But you could pass in whatever code you think is relevant (or none at all). Either way, you'll still get the traceback. Anthony -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.