class HornOfPlenty::Adapters::Github::Error

Constants

STATUS_CODE_ERROR_MAPPING

rubocop:disable Metrics/LineLength

Public Class Methods

lookup(http_status_code, message = nil) click to toggle source

rubocop:enable Metrics/LineLength

# File lib/horn_of_plenty/adapters/github/error.rb, line 20
def self.lookup(http_status_code, message = nil)
  error_data = STATUS_CODE_ERROR_MAPPING[http_status_code]

  fail StandardError, "Unknown Status Code: #{http_status_code}" unless error_data

  error_namespace  = 'HornOfPlenty::Adapters::Github::Errors'
  error_class      = HornOfPlenty::CoreExt::String.constantize(
                       "#{error_namespace}::#{error_data[0]}",
  )

  error_class.new("#{error_data[1]}\n#{message}")
end