Skip to content

Commit 55b02eb

Browse files
committed
Gracefully handle invalid tumblr responses
Querying for invalid usernames would result in a reference error of body being undefined
1 parent 562410b commit 55b02eb

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/request.js

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/request.coffee

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,7 @@ req = (url, method = 'GET', fn, oauth) ->
4848
if not error and response.statusCode not in [200, 301]
4949
error = "#{response.statusCode} #{body.meta.msg}"
5050

51+
unless response?
52+
error = "Invalid Response"
5153
if fn?
52-
fn.call body, error, body.response
54+
fn.call body, error, body?.response

0 commit comments

Comments
 (0)