Could be a little complicated. The relevant code is in gluon.restricted -- see https://github.com/web2py/web2py/blob/4f51647b2f5bd68887ddd9fe139c6bbc0fa885d4/gluon/restricted.py#L115.
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). Anthony On Wednesday, December 13, 2017 at 5:18:40 PM UTC-5, Brendan Barnwell wrote: > > In some situations, when my web2py code raises an exception, what I want > to do is log information about what happened, but then handle it in some > way that doesn't involve the default error handling. The advantage of the > default error handling, though, is that it generates an error ticket. Is > there a way to "manually" generate a ticket, so that I could log the ticket > ID for later inspection, while still attempting to recover from the error? > I'd like to be able to do something like this (inside a function in a > controller or module): > > try: > do_something() > except ValueError as e: > ticket = create_ticket_from_exception_somehow(e) > my_logger.log(ticket.id_number) > # code here to recover from error > > Is there a function like create_ticket_from_exception_somehow? All I can > find in the docs is this: > > """ > > If an exception (other than HTTP) is raised, web2py does the following: > > - Stores the traceback in an error file and assigns a ticket number to > it. > - Rolls back all open database transactions. > - Returns an error page reporting the ticket number. > > """ > > > I want to do just the first part of that: store the traceback with the > ticket number, so I can later view the ticket from the admin interface, but > NOT do anything else --- just give me the ticket number and let me log it > myself. > -- 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.