Class: Calendlyr::ResponseErrorHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/calendlyr/error.rb

Constant Summary collapse

ERROR_TYPES =
{
  "400" => BadRequest,
  "401" => Unauthenticated,
  "403" => PermissionDenied,
  "404" => NotFound,
  "424" => ExternalCalendarError,
  "429" => TooManyRequests,
  "500" => InternalServerError
}

Instance Method Summary collapse

Constructor Details

#initialize(code, body) ⇒ ResponseErrorHandler

Returns a new instance of ResponseErrorHandler.



31
32
33
34
# File 'lib/calendlyr/error.rb', line 31

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

Instance Method Details

#errorObject



36
37
38
39
40
# File 'lib/calendlyr/error.rb', line 36

def error
  return too_many_requests_error if @code == "429"

  error_type.new("[Error #{@code}] #{@body["title"]}. #{@body["message"]}")
end