Skip to content

Commit

Permalink
Merge pull request #120 from FundingCircle/fix-type-error-bug
Browse files Browse the repository at this point in the history
Fix bug that replaces raised exception with TypeError
  • Loading branch information
Cássio Marques committed Jan 2, 2020
2 parents 2c399f9 + fecb724 commit a36383d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [2.5.1] - 2020-01-02
### Fixed
- Fixed a long standing bug that would mask exceptions raised by the host application when serving requests. The original exception would be replaced with a `TypeError` one due to a HTTP status code not being available within `Loga::Rack::Logger`.

## [2.5.0] - 2019-11-12
### Added
- Add support for rails 6
Expand Down
11 changes: 11 additions & 0 deletions gemfiles/rails60.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 6.0.0"

group :test do
gem "simplecov"
end

gemspec path: "../"
3 changes: 3 additions & 0 deletions lib/loga/rack/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def set_data
data['user_agent'] = request.user_agent
data['controller'] = request.controller_action_name if request.controller_action_name
data['duration'] = duration_in_ms(started_at, Time.now)

# If data['status'] is nil we assume an exception was raised when calling the application
data['status'] ||= 500
end
# rubocop:enable Metrics/LineLength

Expand Down
2 changes: 1 addition & 1 deletion lib/loga/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Loga
VERSION = '2.5.0'.freeze
VERSION = '2.5.1'.freeze
end
5 changes: 3 additions & 2 deletions spec/unit/loga/rack/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@
let(:exception) { StandardError.new }
let(:logged_exception) { nil }
let(:response_status) { 200 }
let(:exception_class) { Class.new(StandardError) }

context 'when an exception is raised' do
let(:app) { ->(_env) { raise exception } }
let(:app) { ->(_env) { raise exception_class } }

it 'does not rescue the exception' do
expect { subject.call(env) }.to raise_error(StandardError)
expect { subject.call(env) }.to raise_error(exception_class)
end
end

Expand Down

0 comments on commit a36383d

Please sign in to comment.