Class: Yp::Response::GatewayError::Factory

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, message) ⇒ Factory

Returns a new instance of Factory.



25
26
27
28
# File 'lib/response/gateway_error.rb', line 25

def initialize(code, message)
  @code = code
  @message = message
end

Class Method Details

.error_mapObject



14
15
16
# File 'lib/response/gateway_error.rb', line 14

def error_map
  @error_map ||= load_error_map
end

Instance Method Details

#errorObject



30
31
32
33
34
35
36
37
38
# File 'lib/response/gateway_error.rb', line 30

def error
  if is_missing_field?
    MissingFieldError.new(missing_field)
  elsif is_invalid_field?
    InvalidFieldError.new(invalid_field)
  else
    GatewayError.new(@message)
  end
end