Skip to content

Commit

Permalink
Handle Exception, not just StandardError
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Dec 2, 2017
1 parent 9945a29 commit 02abff3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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
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

0 comments on commit 02abff3

Please sign in to comment.