Exception: FirebaseCloudMessenger::Error
- Inherits:
-
StandardError
- Object
- StandardError
- FirebaseCloudMessenger::Error
show all
- Defined in:
- lib/firebase_cloud_messenger/error.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(response = nil) ⇒ Error
Returns a new instance of Error.
21
22
23
24
25
|
# File 'lib/firebase_cloud_messenger/error.rb', line 21
def initialize(response = nil)
@response = response
super(error_message)
end
|
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
5
6
7
|
# File 'lib/firebase_cloud_messenger/error.rb', line 5
def response
@response
end
|
Class Method Details
.from_response(response) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/firebase_cloud_messenger/error.rb', line 7
def self.from_response(response)
status = response.code
klass = case status.to_i
when 400 then FirebaseCloudMessenger::BadRequest
when 401 then FirebaseCloudMessenger::Unauthorized
when 403 then FirebaseCloudMessenger::Forbidden
when 404 then FirebaseCloudMessenger::NotFound
else self
end
klass.new(response)
end
|
Instance Method Details
#details ⇒ Object
39
40
41
|
# File 'lib/firebase_cloud_messenger/error.rb', line 39
def details
parsed_response["error"]["details"]
end
|
#parsed_response ⇒ Object
35
36
37
|
# File 'lib/firebase_cloud_messenger/error.rb', line 35
def parsed_response
JSON.parse(response_body)
end
|
#response_body ⇒ Object
31
32
33
|
# File 'lib/firebase_cloud_messenger/error.rb', line 31
def response_body
response.body
end
|
#response_status ⇒ Object
27
28
29
|
# File 'lib/firebase_cloud_messenger/error.rb', line 27
def response_status
response.code.to_i
end
|
#short_message ⇒ Object
43
44
45
|
# File 'lib/firebase_cloud_messenger/error.rb', line 43
def short_message
parsed_response["error"]["message"]
end
|