Class Exception
In: lib/core/facets/exception/detail.rb
lib/core/facets/exception/suppress.rb
lib/core/facets/exception/raised.rb
Parent: Object

Methods

detail   raised?   suppress  

Public Class methods

Supress errors while executing a block, with execptions.

CREDIT: David Heinemeier Hansson, Thomas Sawyer

[Source]

    # File lib/core/facets/exception/suppress.rb, line 7
 7:   def self.suppress(*exception_classes)
 8:     exception_classes.each do |e|
 9:       unless e < self
10:         raise ArgumentError, "exception #{e} not a subclass of #{self}"
11:       end
12:     end
13:     begin yield
14:     rescue Exception => e
15:       raise unless exception_classes.any? { |cls| e.kind_of?(cls) }
16:     end
17:   end

Public Instance methods

Pretty string output of exception/error object useful for helpful debug messages.

Input: The Exception/StandardError object

Output: The pretty printed string

CREDIT: George Moschovitis

[Source]

    # File lib/core/facets/exception/detail.rb, line 14
14:   def detail
15:     return %{#{message}\n  #{backtrace.join("\n  ")}\n  LOGGED FROM: #{caller[0]}}
16:   end

Does a block raise an a given exception.

[Source]

    # File lib/core/facets/exception/raised.rb, line 5
 5:   def raised? #:yeild:
 6:     begin
 7:       yield
 8:       false
 9:     rescue self
10:       true
11:     end
12:   end

[Validate]