class Cronofy::Errors

Internal: Helper methods for raising more meaningful errors.

Constants

ERROR_MAP

Public Class Methods

map_error(error) click to toggle source
# File lib/cronofy/errors.rb, line 103
def self.map_error(error)
  raise_error(error.response)
end
raise_error(response) click to toggle source
# File lib/cronofy/errors.rb, line 114
def self.raise_error(response)
  error_class = ERROR_MAP.fetch(response.status, UnknownError)
  raise error_class.new(response.headers['status'], response)
end
raise_if_error(response) click to toggle source
# File lib/cronofy/errors.rb, line 107
def self.raise_if_error(response)
  return if response.status == 200
  raise_error(response)
end