如何进行FaultWrapper解析
发表于:2025-02-02 作者:千家信息网编辑
千家信息网最后更新 2025年02月02日,这篇文章将为大家详细讲解有关如何进行FaultWrapper解析,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。FaultWrapper解析class
千家信息网最后更新 2025年02月02日如何进行FaultWrapper解析
这篇文章将为大家详细讲解有关如何进行FaultWrapper解析,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。
FaultWrapper解析
class FaultWrapper(base_wsgi.Middleware):#继承基础的WSGI中间件"""调用中间件堆栈,将exceptions封装成faults。""" _status_to_type = {}@staticmethod def status_to_type(status): #根据状态码转换成webob相应的类型实例if not FaultWrapper._status_to_type:for clazz in utils.walk_class_hierarchy(webob.exc.HTTPError):# 遍历HTTPError类层次结构 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 = 500 msg_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)#调用exception转换方法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: #处理翻译 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)#调用rpc发送api错误到消息队列return wsgi.Fault(outer) #返回webob.exc.HTTPException错误对象 @webob.dec.wsgify(RequestClass=wsgi.Request)def __call__(self, req):try:return req.get_response(self.application) #执行wsgi应用程序except Exception as ex:return self._error(ex, req)#遇到exception后,调用此方法处理exception,封装成http错误返回
关于如何进行FaultWrapper解析就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。
错误
中间件
内容
文章
更多
知识
篇文章
处理
封装
不错
基础
堆栈
实例
对象
层次
应用程序
方法
此方法
消息
状态
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
服务器生成excel文件
大学新生网络安全培训新闻稿
网络安全防控教育手抄报
智慧党建个性化软件开发支持
广西涉密软件开发资质
2017年8月网络安全
南阳理工网络安全知乎
数据库的精度和标度
保护网络安全的主要手段有哪些
苏州高品质服务器厂家直销价格
启动danjo服务器
天津发展软件开发单价
科东网络安全监测装置2000m
太空狼人杀服务器的应用如何安装
网络安全法 第41条
等级保护测评网络安全
服务器电源都是12v的吗
辽宁网络技术服务包括什么
网络安全协会会长发言稿
教育部网络安全工程师
网络技术店铺名称
广州微淘网络技术有限公司
0基础学软件开发需要多久
网络安全管理制度体系评审表
浦东新区网络技术支持服务
亿君软件开发
网络安全知识内容班会
数据库基础与应用形考四
软件开发设计模型
网络安全要注意手抄报内容