Skip to content
Browse files

Handle errors from Twitter when collecting DMs.

Signed-off-by: Nick Gerakines <nick@gerakines.net>
  • Loading branch information...
1 parent 90d4ad7 commit 4df5d2c647c6274332eaf36d38146302134bb640 Joshua Miller committed with
Showing with 9 additions and 4 deletions.
  1. +9 −4 src/twitter_client.erl
View
13 src/twitter_client.erl
@@ -369,10 +369,15 @@ direct_messages(RootUrl, Login, Password, Args) ->
collect_direct_messages(RootUrl, Login, Password, Page, LowID, Acc) ->
Args = [{"page", integer_to_list(Page)}, {"since_id", integer_to_list(LowID)}],
Messages = twitter_client:direct_messages(RootUrl, Login, Password, Args),
- case length(Messages) of
- 20 -> collect_direct_messages(RootUrl, Login, Password, Page + 1, LowID, [Messages | Acc]);
- 0 -> lists:flatten(Acc);
- _ -> lists:flatten([Messages | Acc])
+ case Messages of
+ error -> lists:flatten(Acc);
+ {error} -> lists:flatten(Acc);
+ _ ->
+ case length(Messages) of
+ 20 -> collect_direct_messages(RootUrl, Login, Password, Page + 1, LowID, [Messages | Acc]);
+ 0 -> lists:flatten(Acc);
+ _ -> lists:flatten([Messages | Acc])
+ end
end.
direct_new(RootUrl, Login, Password, Args) ->

0 comments on commit 4df5d2c

Please sign in to comment.
Something went wrong with that request. Please try again.