Skip to content

Commit 7f3f032

Browse files
committed
create a fcm error class
1 parent 813faae commit 7f3f032

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

lib/fcm/error.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# frozen_string_literal: true
2+
3+
module Fcm
4+
# Custom Fcm errors
5+
class Error < StandardError
6+
ERROR_RESPONSE_400 = 'Only applies for JSON requests.'\
7+
' Indicates that the request could not be parsed as JSON,'\
8+
' or it contained invalid fields.'
9+
10+
ERROR_RESPONSE_401 = 'There was an error authenticating'\
11+
' the sender account.'
12+
13+
ERROR_RESPONSE_503 = 'Server is temporarily unavailable.'
14+
15+
ERROR_RESPONSE_50X = 'There was an internal error in the'\
16+
' FCM server while trying to process the request.'
17+
end
18+
19+
# Raised on errors in the 400-499 range
20+
class ClientError < Error; end
21+
22+
# Raised when Faraday returns a 400 HTTP status code
23+
class BadRequest < ClientError; end
24+
25+
# Raised when Faraday returns a 401 HTTP status code
26+
class Unauthorized < ClientError; end
27+
28+
# Raised on errors in the 500-599 range
29+
class ServerError < Error; end
30+
31+
# Raised when Faraday returns a 503 HTTP status code
32+
class ServiceUnavailable < ServerError; end
33+
end

0 commit comments

Comments
 (0)