Skip to content

Commit

Permalink
Merge pull request #51 from gregwebs/exception
Browse files Browse the repository at this point in the history
save exception in rack.exception
  • Loading branch information
gregwebs committed May 17, 2011
2 parents fd874ec + b9f90cd commit 87ecf4a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/goliath/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,14 @@ def call(env)
end

rescue Goliath::Validation::Error => e
env['rack.exception'] = e
env[ASYNC_CALLBACK].call(validation_error(e.status_code, e.message))

rescue Exception => e
env.logger.error(e.message)
env.logger.error(e.backtrace.join("\n"))

env[ASYNC_CALLBACK].call(validation_error(400, e.message))
env[RACK_EXCEPTION] = e
env[ASYNC_CALLBACK].call(validation_error(500, e.message))
end
}.resume

Expand Down
1 change: 1 addition & 0 deletions lib/goliath/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module Constants
RACK_RUN_ONCE = 'rack.run_once'
RACK_VERSION_NUM = [1, 0]
RACK_LOGGER = 'rack.logger'
RACK_EXCEPTION = 'rack.exception'

ASYNC_CALLBACK = 'async.callback'
ASYNC_HEADERS = 'async.headers'
Expand Down

0 comments on commit 87ecf4a

Please sign in to comment.