Exception: Exception

Defined in:
lib/gtk2applib/core_hacks.rb

Overview

Exception is Ruby core. I'm just adding puts_bang!.

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) puts_bang!(header = '', trailer = '', bang = Exception)

Class method version of puts_bang!



29
30
31
32
33
34
35
36
37
38
# File 'lib/gtk2applib/core_hacks.rb', line 29

def self.puts_bang!(header='', trailer='', bang=Exception)
  error = nil
  begin
    yield
  rescue bang
    $!.puts_bang!(header, trailer)
    error = $!
  end
  return error
end

Instance Method Details

- (Object) puts_bang!(header = '', trailer = '')

puts_bang! outputs to standard error what went bang! If the application is running in quiet mode, no output occurs. If the application is running in verbose mode, a backtrace is also given. This output can be headed and tailed with additional application supplied information. It's expected that the application will report errors via puts_bang!.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gtk2applib/core_hacks.rb', line 12

def puts_bang!(header='', trailer='')
  if !$quiet then
    begin
      $stderr.puts header
      $stderr.puts self.message
      $stderr.puts self.backtrace.to_s if $verbose
      $stderr.puts trailer
    rescue Exception
      # no stderr?
    end
  end
end