Skip to content
Myr

When Accept includes text/html display exceptions otherwise 500

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by visionmedia · committed by visionmedia · parent f416473 · Browse files · 3 files+18 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+18 added−2 removed

  • other:+18 added−2 removed

3 files+18 added−2 removed

modified:examples/app.js+1 added-1 removed
modified:lib/express/core.js+4 added-1 removed
256 unmodified lines
257 if (typeof (body = Express.router.route(request)) == 'string')258 halt(200, body)259 }260 catch (e) {261 if (accepts('html'))261 halt(500, require('express/show-exceptions').render(e))262 halt(500, require('express/show-exceptions').render(e))263 else264 halt(500)265 }266 },267 268 /**
33 unmodified lines
modified:lib/express/helpers.js+13 added
102 unmodified lines
103 Express.server.request.uri.params[key]104}105106/**107 * Check if Accept header includes the mime type108 * for the given _path_, which calls mime().109 *110 * @param {string} path111 * @see mime()112 * @api public113 */114115exports.accepts = function(path) {116 return header('accept').indexOf(mime(path)) != -1117}118119/**120 * Set response header _key_ and _val_ or get121 * request header value by _key_.122 *123 * @param {string} key
162 unmodified lines