我想我可能在使用金字塔和处理自定义错误代码/异常时遇到问题
在后端应用程序中,我提出了一个errareCatalog.errExtapiFulfillIdDeprecated
当一个特定的事件发生时,我不认为这是有意义的,但下面是我在errareCatalog.py
中提出的:
class errExtapiFulfillIdDeprecated(errare.processingErrare):
e_mnemonic = 'ERR_FULFILL_ID_DEPRECATED'
e_baseMsg = gettext('Fulfill id is deprecated')
e_errCatalogNumber = -21008
我试图通过以下方式在前端部分捕获此异常:
from pyramid.httpexceptions import HTTPNotFound
from hll.errors import errareCatalog
try :
stuff that raise and exception
except errareCatalog.errExtapiFulfillIdDeprecated as ex :
request.response.status_code = 404
print 'throwin 404'
return HTTPNotFound()
问题是,我似乎从来没有参与过这个,除了。在某个地方抛出了一个500错误,并将我重定向到500页。 我是不是在提升/捕获异常的方式上做错了什么,或者金字塔中缺少了配置?你知道吗
编辑:这是我的异常视图
@view_config(context=errareCatalog.errExtapiFulfillIdDeprecated, permission=NO_PERMISSION_REQUIRED)
def mobile_ticket_error(exc, request):
print 'test error'
logger.exception("DEPRECATED FULFILLID: %s" % str(exc))
return render_to_response("mylogin:templates/mobile-ticket-error.genshi",
{'message': str(exc),
'layout_name': get_layout_name(request)},
request=request)
目前没有回答
相关问题 更多 >
编程相关推荐