Exception: Simple::HTTP::StatusError

Inherits:
Error
  • Object
show all
Defined in:
lib/simple/http/errors.rb

Direct Known Subclasses

Status4XXError, Status5XXError

Instance Attribute Summary

Attributes inherited from Error

#response

Class Method Summary collapse

Methods inherited from Error

#initialize, #message, #request, #status, #verb

Constructor Details

This class inherits a constructor from Simple::HTTP::Error

Class Method Details

.raise(response:) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/simple/http/errors.rb', line 34

def self.raise(response:)
  error_klass = case response.status
                when 400..499 then ::Simple::HTTP::Status4XXError
                when 500..599 then ::Simple::HTTP::Status5XXError
                else ::Simple::HTTP::StatusError
                end

  Kernel.raise error_klass.new(response)
end