make rack tell you when a request goes wonky

This commit is contained in:
John Bintz 2012-04-11 16:35:29 -04:00
parent 668ef51cef
commit b94df1c3a0
4 changed files with 34 additions and 27 deletions

View File

@ -1,7 +1,3 @@
#= require_self
#= require flowerbox/result
#= require flowerbox/exception
#
Flowerbox = Flowerbox =
debug: false debug: false
ping: -> ping: ->
@ -37,3 +33,25 @@ Flowerbox =
fail: -> fail: ->
class Flowerbox.Exception
constructor: (@source, @name, @stack) ->
toJSON: ->
{ status: Flowerbox.Result.FAILURE, source: @source, name: @name, trace: { stack: @stack } }
class Flowerbox.Result
@SUCCESS = 'success'
@PENDING = 'pending'
@UNDEFINED = 'undefined'
@FAILURE = 'failure'
@SKIPPED = 'skipped'
constructor: (data) ->
for key, value of data
this[key] = value
this.status ||= Flowerbox.Result.SKIPPED
this.failures ||= []
toJSON: => this

View File

@ -1,5 +0,0 @@
class Flowerbox.Exception
constructor: (@source, @name, @stack) ->
toJSON: ->
{ status: Flowerbox.Result.FAILURE, source: @source, name: @name, trace: { stack: @stack } }

View File

@ -1,17 +0,0 @@
Flowerbox ||= {}
class Flowerbox.Result
@SUCCESS = 'success'
@PENDING = 'pending'
@UNDEFINED = 'undefined'
@FAILURE = 'failure'
@SKIPPED = 'skipped'
constructor: (data) ->
for key, value of data
this[key] = value
this.status ||= Flowerbox.Result.SKIPPED
this.failures ||= []
toJSON: => this

View File

@ -17,7 +17,18 @@ module Flowerbox
result result
else else
[ 200, { 'Content-type' => 'text/html' }, [ runner.template ] ] begin
template = runner.template
[ 200, { 'Content-type' => 'text/html' }, [ template ] ]
rescue => e
$stderr.puts
$stderr.puts e.message
$stderr.puts e.backtrace.join("\n")
$stderr.puts
[ 500, {}, [] ]
end
end end
end end
end end