Class: GrpcMock::Response::ExceptionValue

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

Instance Method Summary collapse

Constructor Details

#initialize(exception) ⇒ ExceptionValue

Returns a new instance of ExceptionValue.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/grpc_mock/response.rb', line 6

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

Instance Method Details

#evaluate(_request = nil, _call = nil) ⇒ Object



19
20
21
# File 'lib/grpc_mock/response.rb', line 19

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