i think i might have a problem using pyramid and dealing with custom error code / exception
In the back end application, im raising a errareCatalog.errExtapiFulfillIdDeprecated
when a specific events occurs, i dont think it's significant but here's what i'm raising in my errareCatalog.py
:
class errExtapiFulfillIdDeprecated(errare.processingErrare):
e_mnemonic = 'ERR_FULFILL_ID_DEPRECATED'
e_baseMsg = gettext('Fulfill id is deprecated')
e_errCatalogNumber = -21008
I'm trying to catch this exception in the front end part this way :
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()
The problem is, i never seem to enter in this except. A 500 error is thrown somewhere and redirect me to the 500 page. Am i doing something wrong with the way i raise / catch exceptions or do i have a configuration missing in Pyramid ?
Edit : here's my exception view
@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)