diff --git a/lib/web_push/errors.rb b/lib/web_push/errors.rb index e4fa313..2554e8a 100644 --- a/lib/web_push/errors.rb +++ b/lib/web_push/errors.rb @@ -26,4 +26,6 @@ class PayloadTooLarge < ResponseError; end class TooManyRequests < ResponseError; end class PushServiceError < ResponseError; end + + class EdgeThrottled < ResponseError; end end diff --git a/lib/web_push/request.rb b/lib/web_push/request.rb index 7b8780a..71a581d 100644 --- a/lib/web_push/request.rb +++ b/lib/web_push/request.rb @@ -147,6 +147,8 @@ def verify_response(resp) elsif resp.is_a?(Net::HTTPUnauthorized) || resp.is_a?(Net::HTTPForbidden) || # 401, 403 resp.is_a?(Net::HTTPBadRequest) && resp.message == 'UnauthorizedRegistration' # 400, Google FCM raise Unauthorized.new(resp, uri.host) + elsif resp.is_a?(Net::HTTPNotAcceptable) && uri.host.to_s.ends_with?("notify.windows.com") #406 on Edge + raise EdgeThrottled.new(resp, uri.host) elsif resp.is_a?(Net::HTTPRequestEntityTooLarge) # 413 raise PayloadTooLarge.new(resp, uri.host) elsif resp.is_a?(Net::HTTPTooManyRequests) # 429, try again later!