Class: ProtoPharm::Response::ExceptionValue

Inherits:
Object
  • Object
show all
Defined in:
lib/proto_pharm/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ ExceptionValue

Returns a new instance of ExceptionValue.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/proto_pharm/response.rb', line 8

def initialize(exception)
  @exception = case exception
               when String
                 StandardError.new(exception)
               when Class
                 exception.new("Exception from ProtoPharm")
               when Exception
                 exception
               else
                 raise ArgumentError.new(message: "Invalid exception class: #{exception.class}")
               end
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



6
7
8
# File 'lib/proto_pharm/response.rb', line 6

def exception
  @exception
end

Instance Method Details

#evaluate(_request = nil) ⇒ Object



21
22
23
# File 'lib/proto_pharm/response.rb', line 21

def evaluate(_request = nil)
  raise @exception.dup
end