Skip to content

Commit

Permalink
Add config & CLI option for "raise on error"
Browse files Browse the repository at this point in the history
- otherwise, templating errors won't fail the process
  • Loading branch information
aharpervc committed Nov 15, 2023
1 parent 844e766 commit 24e3a11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/consult/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def parse_options(argv)
opts[:force_render] = arg
end

o.on '--raise-on-error', FalseClass, 'Raise errors instead of printing them' do |arg|
opts[:raise_on_error] = arg
end

o.on '--quiet', FalseClass, 'Silence output' do |arg|
opts[:verbose] = arg
end
Expand Down
5 changes: 5 additions & 0 deletions lib/consult/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def render(save: true)
result
rescue StandardError => e
STDERR.puts "Error rendering template: #{name}"

if @config[:raise_on_error]
raise e
end

STDERR.puts e
STDERR.puts e.backtrace if verbose?
nil
Expand Down

0 comments on commit 24e3a11

Please sign in to comment.