Skip to content

Commit 1bdb912

Browse files
committed
Add nil check for request before calling methods
Demeter: It's the law. This will allow the token auth object to respond with nill if the response was never created or set to nil for some reason.
1 parent 7158b1f commit 1bdb912

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/kracken/token_authenticator.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ def fetch(token)
1919
end
2020

2121
def body
22-
JSON.parse(response.body)
22+
if response
23+
JSON.parse(response.body)
24+
end
2325
end
2426

2527
def etag
26-
response.headers["etag"]
28+
if response
29+
response.headers["etag"]
30+
end
2731
end
2832

2933
private

0 commit comments

Comments
 (0)