Skip to content

Commit

Permalink
Make Errno::EADDRINUSE not print a stack trace
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Oct 23, 2017
1 parent 682f468 commit b024adb
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions lib/nanoc/cli/error_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@ def handle_while(&_block)

# Run
yield
rescue Nanoc::Int::Errors::GenericTrivial => e
$stderr.puts "Error: #{e.message}"
exit(1)
rescue Interrupt
exit(1)
rescue StandardError, ScriptError => e
print_error(e)
if trivial?(e)
$stderr.puts "Error: #{e.message}"
resolution = resolution_for(e)
$stderr.puts resolution if resolution
else
print_error(e)
end
exit(1)
end

Expand Down Expand Up @@ -191,6 +194,15 @@ def gems_and_versions
'w3c_validators' => 'w3c_validators',
}.freeze

def trivial?(error)
case error
when Nanoc::Int::Errors::GenericTrivial, Errno::EADDRINUSE
true
else
false
end
end

# Attempts to find a resolution for the given error, or nil if no
# resolution can be automatically obtained.
#
Expand Down

0 comments on commit b024adb

Please sign in to comment.