From b94df1c3a08e703656a5515ad08de5334c3d2264 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 11 Apr 2012 16:35:29 -0400 Subject: [PATCH] make rack tell you when a request goes wonky --- lib/assets/javascripts/flowerbox.js.coffee | 26 ++++++++++++++++--- .../javascripts/flowerbox/exception.js.coffee | 5 ---- .../javascripts/flowerbox/result.js.coffee | 17 ------------ lib/flowerbox/rack.rb | 13 +++++++++- 4 files changed, 34 insertions(+), 27 deletions(-) delete mode 100644 lib/assets/javascripts/flowerbox/exception.js.coffee delete mode 100644 lib/assets/javascripts/flowerbox/result.js.coffee diff --git a/lib/assets/javascripts/flowerbox.js.coffee b/lib/assets/javascripts/flowerbox.js.coffee index 105326f..eb0414e 100644 --- a/lib/assets/javascripts/flowerbox.js.coffee +++ b/lib/assets/javascripts/flowerbox.js.coffee @@ -1,7 +1,3 @@ -#= require_self -#= require flowerbox/result -#= require flowerbox/exception -# Flowerbox = debug: false ping: -> @@ -37,3 +33,25 @@ Flowerbox = 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 + diff --git a/lib/assets/javascripts/flowerbox/exception.js.coffee b/lib/assets/javascripts/flowerbox/exception.js.coffee deleted file mode 100644 index e6903a7..0000000 --- a/lib/assets/javascripts/flowerbox/exception.js.coffee +++ /dev/null @@ -1,5 +0,0 @@ -class Flowerbox.Exception - constructor: (@source, @name, @stack) -> - - toJSON: -> - { status: Flowerbox.Result.FAILURE, source: @source, name: @name, trace: { stack: @stack } } diff --git a/lib/assets/javascripts/flowerbox/result.js.coffee b/lib/assets/javascripts/flowerbox/result.js.coffee deleted file mode 100644 index cf412a4..0000000 --- a/lib/assets/javascripts/flowerbox/result.js.coffee +++ /dev/null @@ -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 diff --git a/lib/flowerbox/rack.rb b/lib/flowerbox/rack.rb index 1f37fba..b1c5c84 100644 --- a/lib/flowerbox/rack.rb +++ b/lib/flowerbox/rack.rb @@ -17,7 +17,18 @@ module Flowerbox result 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