Skip to content
Myr

Added "show exceptions" setting and specs

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

authored by visionmedia · committed by visionmedia · parent 52b29b6 · Browse files · 3 files+26 added−1 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+26 added−1 removed

  • tests:+24 added−0 removed
  • other:+2 added−1 removed

3 files+26 added−1 removed

modified:examples/app.js+1 added
modified:lib/express/core.js+1 added-1 removed
258 unmodified lines
259 }260 catch (e) {261 if (e instanceof ExpressError)262 throw e263 if (accepts('html'))263 if (accepts('html') && set('show exceptions'))264 halt(500, require('express/show-exceptions').render(e))265 else266 halt(500)267 }
36 unmodified lines
modified:spec/spec.routing.js+24 added
173 unmodified lines
174 get('/something').body.should.eql 'Not Found'175 end176 end177 178 describe 'with an exception thrown'179 describe 'with "show exceptions" enabled'180 it 'should show the exception html'181 enable('show exceptions')182 get('/user', function(){183 throw new Error('Access Denied')184 })185 get('/user').status.should.eql 500186 get('/user').body.should.include('<h1>Express</h1>')187 get('/user').body.should.include('<h2><em>500</em> Error: Access Denied</h2>')188 end189 end190 191 describe 'with "show exceptions" disabled'192 it 'should show the regular body'193 get('/user', function(){194 throw new Error('Access Denied')195 })196 get('/user').status.should.eql 500197 get('/user').body.should.include('Internal Server Error')198 end199 end200 end201 202 end203end