var lf_error = function( po_request, po_resource, pn_number, pc_message ) {
var lo_error = {
'errormessage' : po_request.i18n.__('global_error', po_request.url, pc_message || ''),
'errorcode' : pn_number || 500
};
po_resource.status(lo_error.errorcode);
// handle different result types
if (po_request.accepts('html'))
{
po_resource.render( 'error', lo_error );
return;
}
if (po_request.accepts('json'))
{
po_resource.send( lo_error );
return;
}
po_resource.type('txt').send( lo_error.errormessage );
}
po_application.use(function(po_request, po_resource, po_next ) {
lf_error(po_request, po_resource, 404);
});
po_application.use(function(po_error, po_request, po_resource, po_next ) {
lf_error(po_request, po_resource, 500, po_error.message);
});
all three files exists within the static content and the error is also reported on all other Jade templates. If I remove the two error handlers, the normale templates works well.
I would like to define an own error Jade template for all errors within my application (exception throwing with a 500 error and non-existing files with 404). How can I do this in a correct way?