Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Exception, not just StandardError #1258

Merged
merged 1 commit into from Dec 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/nanoc/base/services/compiler/stages/compile_reps.rb
Expand Up @@ -26,7 +26,7 @@ def run

def handle_errors_while(item_rep)
yield
rescue => e
rescue Exception => e # rubocop:disable Lint/RescueException
raise Nanoc::Int::Errors::CompilationError.new(e, item_rep)
end

Expand Down
6 changes: 3 additions & 3 deletions spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb
Expand Up @@ -113,7 +113,7 @@
end

context 'exception' do
let(:item) { Nanoc::Int::Item.new('<%= raise "lol" %>', {}, '/hi.md') }
let(:item) { Nanoc::Int::Item.new('<%= \'invalid_ruby %>', {}, '/hi.md') }

it 'wraps exception' do
expect { subject }.to raise_error(Nanoc::Int::Errors::CompilationError)
Expand All @@ -127,8 +127,8 @@

it 'contains the right wrapped exception' do
expect { subject }.to raise_error do |err|
expect(err.unwrap).to be_a(RuntimeError)
expect(err.unwrap.message).to eq('lol')
expect(err.unwrap).to be_a(SyntaxError)
expect(err.unwrap.message).to start_with('item /hi.md (rep default):1: unterminated string meets end of file')
end
end

Expand Down