Exception: ApiRecipes::ResponseCodeNotAsExpected

Inherits:
Exception
  • Object
show all
Defined in:
lib/api_recipes/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, expected_code = nil, response = nil, message: nil) ⇒ ResponseCodeNotAsExpected

Returns a new instance of ResponseCodeNotAsExpected.



46
47
48
49
50
51
52
53
54
# File 'lib/api_recipes/exceptions.rb', line 46

def initialize(path, expected_code = nil, response = nil, message: nil)
  @path = path
  @expected_code = expected_code
  @response = response
  unless message
    message = "response code for request on route '#{@path}' has returned '#{@response.code}', but '#{@expected_code}' was expected\n\nResponse body:\n #{@response.body}"
  end
  super(message)
end

Instance Attribute Details

#expected_codeObject (readonly)

Returns the value of attribute expected_code.



44
45
46
# File 'lib/api_recipes/exceptions.rb', line 44

def expected_code
  @expected_code
end

#pathObject (readonly)

Returns the value of attribute path.



44
45
46
# File 'lib/api_recipes/exceptions.rb', line 44

def path
  @path
end

#responseObject (readonly)

Returns the value of attribute response.



44
45
46
# File 'lib/api_recipes/exceptions.rb', line 44

def response
  @response
end