Module: Webmachine::RescuableException

Defined in:
lib/webmachine/rescueable_exception.rb

Constant Summary collapse

UNRESCUABLE_DEFAULTS =
[
  Webmachine::MalformedRequest,
  NoMemoryError, SystemExit, SignalException
].freeze

Class Method Summary collapse

Class Method Details

.===(e) ⇒ Object



13
14
15
16
17
18
# File 'lib/webmachine/rescueable_exception.rb', line 13

def self.===(e)
  case e
  when *UNRESCUABLE then false
  else true
  end
end

.add(*exceptions) ⇒ Object

Add a variable number of exceptions that should be rescued by Webmachine::Resource#handle_exception. See UNRESCUABLE_DEFAULTS for a list of exceptions that are not caught by default.



47
48
49
# File 'lib/webmachine/rescueable_exception.rb', line 47

def self.add(*exceptions)
  exceptions.each{|e| UNRESCUABLE.delete(e)}
end

.default!nil

Remove modifications to Webmachine::RescuableException. Restores default list of unrescue-able exceptions.

Returns:

  • (nil)


26
27
28
29
# File 'lib/webmachine/rescueable_exception.rb', line 26

def self.default!
  UNRESCUABLE.replace Set.new(UNRESCUABLE_DEFAULTS.dup)
  nil
end

.remove(*exceptions) ⇒ Object

Remove a variable number of exceptions from being rescued by Webmachine::Resource#handle_exception. See UNRESCUABLE_DEFAULTS for a list of exceptions that are not caught by default.

Parameters:

  • *exceptions (Exception)

    A subclass of Exception.



59
60
61
# File 'lib/webmachine/rescueable_exception.rb', line 59

def self.remove(*exceptions)
  exceptions.each{|e| UNRESCUABLE.add(e)}
end

.UNRESCUABLEsArray<Exception>

Returns an Array of exceptions that will not be rescued by Webmachine::Resource#handle_exception.

Returns:

  • (Array<Exception>)

    Returns an Array of exceptions that will not be rescued by Webmachine::Resource#handle_exception.



36
37
38
# File 'lib/webmachine/rescueable_exception.rb', line 36

def self.UNRESCUABLEs
  UNRESCUABLE.to_a
end