lib/honeybadger/backend/base.rb in honeybadger-2.7.2 vs lib/honeybadger/backend/base.rb in honeybadger-3.0.0.beta1

- old
+ new

@@ -9,10 +9,17 @@ class Response NOT_BLANK = /\S/ attr_reader :code, :body, :message, :error + FRIENDLY_ERRORS = { + 429 => "Your project is currently sending too many errors.\nThis issue should resolve itself once error traffic is reduced.".freeze, + 503 => "Your project is currently sending too many errors.\nThis issue should resolve itself once error traffic is reduced.".freeze, + 402 => "The project owner's billing information has expired (or the trial has ended).\nPlease check your payment details or email support@honeybadger.io for help.".freeze, + 403 => "The API key is invalid. Please check your API key and try again.".freeze + }.freeze + # Public: Initializes the Response instance. # # response - With 1 argument Net::HTTPResponse, the code, body, and # message will be determined automatically. (optional) # code - The Integer status code. May also be :error for requests which @@ -33,9 +40,13 @@ @error = parse_error(body) unless @success end def success? @success + end + + def error_message + FRIENDLY_ERRORS[code] || message end private def parse_error(body)