Skip to content

Commit 4c591b2

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 4c591b2

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,8 @@ 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 body.response?
52+
error = "Invalid Response"
53+
5154
if fn?
52-
fn.call body, error, body.response
55+
fn.call body, error, body?.response

0 commit comments

Comments
 (0)