def translate_exception(req, e):
 if (not hasattr(req, 'best_match_language')):
  return e
 locale = req.best_match_language()
 if isinstance(e, webob.exc.HTTPError):
  e.explanation = i18n.translate(e.explanation, locale)
  e.detail = i18n.translate(e.detail, locale)
  if getattr(e, 'body_template', None):
   e.body_template = i18n.translate(e.body_template, locale)
 return e

def translate_exception ( req , e ) : if ( not hasattr ( req , 'best_match_language' ) ) : return e locale = req . best_match_language ( ) if isinstance ( e , webob . exc . HTTPError ) : e . explanation = i18n . translate ( e . explanation , locale ) e . detail = i18n . translate ( e . detail , locale ) if getattr ( e , 'body_template' , None ) : e . body_template = i18n . translate ( e . body_template , locale ) return e
if passed an exc_info it will automatically rewrite the exceptions all the way down to the correct line numbers and frames .