In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article will explain in detail how to parse FaultWrapper. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.
FaultWrapper parses class FaultWrapper (base_wsgi.Middleware): # inherits the basic WSGI middleware "" invokes the middleware stack and encapsulates exceptions into faults. " _ status_to_type = {} @ staticmethod def status_to_type (status): # convert to the corresponding type instance if not FaultWrapper._status_to_type:for clazz in utils.walk_class_hierarchy (webob.exc.HTTPError) of webob according to the status code: # traverse the HTTPError class hierarchy construction FaultWrapper._status_to_ type [clazz.code] = clazzreturn FaultWrapper._status_to_type.get ( Status Webob.exc.HTTPInternalServerError) () def _ error (self, inner, req): LOG.exception (_ LE ("Caught error:% s"), inner) safe = getattr (inner, 'safe', False) headers = getattr (inner,' headers', None) status = getattr (inner, 'code', 500) if status is None: status = 500msg_dict = dict (url=req.url Status=status) LOG.info (_ LI ("% (url) s returned with HTTP% (status) d"), msg_dict) outer = self.status_to_type (status) # call the exception conversion method if headers: outer.headers = headers# NOTE (johannes): We leave the explanation empty here on # purpose. It could possibly have sensitive information # that should not be returned back to the user. See # bugs 868360 and 874472 # NOTE (eglynn): However, it would be over-conservative and # inconsistent with the EC2 API to hide every exception, # including those that are safe to expose, see bug 1021373 if safe: # process translation user_locale = req.best_match_language () inner_msg = translate (inner.message User_locale) outer.explanation ='% s:% s'% (inner.__class__.__name__, inner_msg) notifications.send_api_fault (req.url, status) Inner) # call rpc to send api error to message queue return wsgi.Fault (outer) # return webob.exc.HTTPException error object @ webob.dec.wsgify (RequestClass=wsgi.Request) def _ _ call__ (self, req): try:return req.get_response (self.application) # execute wsgi application except Exception as ex:return self._error (ex, req) # after encountering exception Call this method to deal with exception, encapsulated as http error return, so much for sharing on how to parse FaultWrapper. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.