Skip to content
Myr

Added "throw exceptions" options

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

Propegates anything thrown to the global scope

authored by visionmedia · committed by visionmedia · parent dad297e · Browse files · 4 files+27 added−3 removed
This commit

State

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

Diff stats

4 files+27 added−3 removed

  • tests:+24 added−3 removed
  • other:+3 added−0 removed

4 files+27 added−3 removed

modified:examples/app.js+1 added
modified:lib/express/core.js+2 added
262 unmodified lines
263 if (accepts('html') && set('show exceptions'))264 halt(500, require('express/show-exceptions').render(e))265 else266 halt(500)267 if (set('throw exceptions'))268 throw e269 }270 },271 272 /**
33 unmodified lines
modified:spec/spec.core.js+3 added-3 removed
modified:spec/spec.routing.js+21 added
187 unmodified lines
188 end189 end190 191 describe 'with "show exceptions" disabled'192   disable('show exceptions')193 it 'should show the regular body'194 get('/user', function(){195 throw new Error('Access Denied')196 })197 get('/user').status.should.eql 500198 get('/user').body.should.include('Internal Server Error')199 end200 end201 202 describe 'with "throw exceptions" enabled'203 it 'should propegate to the global scope'204 enable('throw exceptions')205 get('/user', function(){206 throw new Error('Access Denied')207 })208 -{ get('/user') }.should.throw_error209 end210 end211 212 describe 'with "throw exceptions" disabled'213 it 'should not propegate to the global scope'214 disable('throw exceptions')215 get('/user', function(){216 throw new Error('Access Denied')217 })218 -{ get('/user') }.should.not.throw_error219 end220 end221 end222 223 end224end