I created a minimal test case. The exception raised by the view is caught by pyramid_debugtoolbar. The exception raised by the NewRequest callback is caught but isn't displayed correctly because requests to /_debug_toolbar/* hit the same exception.
I can fix this by returning early from the callback if PATH_INFO starts with /_debug_toolbar, but maybe there's a better way.
But this is a bit different from what I'm seeing in my actual app, which is that the exeption doesn't appear to be caught at all. More investigation under way...
from waitress import serve
from pyramid.config import Configurator
from pyramid.events import NewRequest
def main(global_config, **settings):
settings['pyramid.includes'] = ['pyramid_debugtoolbar']
config = Configurator(settings=settings)
def callback(event):
something()
#config.add_subscriber(callback, NewRequest)
config.add_route('route', '/route')
config.add_view(view, route_name='route', renderer='string')
app = config.make_wsgi_app()
return app
def view(request):
return xxx
def something():
raise Exception
if __name__ == '__main__':
app = main({})
serve(app)