lib/nanoc/cli/error_handler.rb
# Enables error handling in the given block. This method should not be
# called directly; use {Nanoc::CLI::ErrorHandler.handle_while} instead.
#
# @return [void]
#
# @api private
Enables error handling in the given block. This method should not be
called directly; use {Nanoc::CLI::ErrorHandler.handle_while} instead.
Enables error handling in the given block . This method should not be called directly ; use { Nanoc :: CLI :: ErrorHandler . handle_while } instead .
def handle_while(&block)
      [ 'INT', 'TERM' ].each do |signal|
        Signal.trap(signal) do
          puts
          exit!(0)
        end
      end
      begin
        Signal.trap('USR1') do
          puts "Caught USR1; dumping a stack trace"
          puts caller.map { |i| "  #{i}" }.join("\n")
        end
      rescue ArgumentError
      end
      yield
    rescue Nanoc::Errors::GenericTrivial => e
      $stderr.puts "Error: #{e.message}"
      exit(1)
    rescue Interrupt => e
      exit(1)
    rescue StandardError, ScriptError => e
      self.print_error(e)
      exit(1)
    end
def handle_while ( & block ) [ 'INT' , 'TERM' ] . each do | signal | Signal . trap ( signal ) do puts exit! ( 0 ) end end begin Signal . trap ( 'USR1' ) do puts "Caught USR1; dumping a stack trace" puts caller . map { | i | "  #{i}" } . join ( "\n" ) end rescue ArgumentError end yield rescue Nanoc :: Errors :: GenericTrivial => e $stderr . puts "Error: #{e.message}" exit ( 1 ) rescue Interrupt => e exit ( 1 ) rescue StandardError , ScriptError => e self . print_error ( e ) exit ( 1 ) end
Enables error handling in the given block.
Enables error handling in the given block .
# Set exit handler # Run
None
void
block
api
None