def catch_errors_app(application, environ, start_response, error_callback_app, ok_callback=None, catch=Exception):
 try:
  app_iter = application(environ, start_response)
 except catch:
  return error_callback_app(environ, start_response, sys.exc_info())
 if (type(app_iter) in (list, tuple)):
  if (ok_callback is not None):
   ok_callback()
  return app_iter
 else:
  return _wrap_app_iter_app(environ, start_response, app_iter, error_callback_app, ok_callback, catch=catch)

def catch_errors_app ( application , environ , start_response , error_callback_app , ok_callback = None , catch = Exception ) : try : app_iter = application ( environ , start_response ) except catch : return error_callback_app ( environ , start_response , sys . exc_info ( ) ) if ( type ( app_iter ) in ( list , tuple ) ) : if ( ok_callback is not None ) : ok_callback ( ) return app_iter else : return _wrap_app_iter_app ( environ , start_response , app_iter , error_callback_app , ok_callback , catch = catch )
like catch_errors .