Skip to content

Commit

Permalink
Merge f62185d into 4bb7f17
Browse files Browse the repository at this point in the history
  • Loading branch information
troyk committed Mar 15, 2014
2 parents 4bb7f17 + f62185d commit 03ec2b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/lotus/action/throwable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ def status(code, message)
self.body = message
end

# The exception raised during call (if any)
def error
@_error
end

private
def _rescue
catch :halt do
Expand All @@ -123,6 +128,7 @@ def _rescue
end

def _handle_exception(exception)
@_error = exception
throw self.class.handled_exceptions.fetch(exception.class, 500)
end
end
Expand Down
6 changes: 6 additions & 0 deletions test/throw_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,11 @@ def call(params)
response[0].must_equal 408
response[2].must_equal ['Request Timeout']
end

it 'provides access to the exception via error attribute' do
action = ErrorCallAction.new
response = action.call({})
action.send(:error).class.must_equal RuntimeError
end
end
end

0 comments on commit 03ec2b0

Please sign in to comment.