def excview_tween_factory(handler, registry):
 def excview_tween(request):
  attrs = request.__dict__
  try:
   response = handler(request)
  except Exception as exc:
   attrs['exc_info'] = sys.exc_info()
   attrs['exception'] = exc
   if ('response' in attrs):
    del attrs['response']
   request_iface = attrs.get('request_iface', IRequest)
   provides = providedBy(exc)
   try:
    response = _call_view(registry, request, exc, provides, '', view_classifier=IExceptionViewClassifier, request_iface=request_iface.combined)
   except PredicateMismatch:
    response = None
   if (response is None):
    reraise(*attrs['exc_info'])
  return response
 return excview_tween

def excview_tween_factory ( handler , registry ) : def excview_tween ( request ) : attrs = request . __dict__ try : response = handler ( request ) except Exception as exc : attrs [ 'exc_info' ] = sys . exc_info ( ) attrs [ 'exception' ] = exc if ( 'response' in attrs ) : del attrs [ 'response' ] request_iface = attrs . get ( 'request_iface' , IRequest ) provides = providedBy ( exc ) try : response = _call_view ( registry , request , exc , provides , '' , view_classifier = IExceptionViewClassifier , request_iface = request_iface . combined ) except PredicateMismatch : response = None if ( response is None ) : reraise ( * attrs [ 'exc_info' ] ) return response return excview_tween
a :term:tween factory which produces a tween that catches an exception raised by downstream tweens and .