Skip to content

Commit

Permalink
[rostwitter] Add error_code to check error (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
nakane11 authored Sep 22, 2022
1 parent 46123bf commit 30faf99
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions rostwitter/python/rostwitter/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,14 @@ def _request_url(self, url, verb, data=None):

def _check_post_request(self, request):
valid = True
if request.status_code == 200:
if request.status_code != 200:
data = simplejson.loads(request.content)
rospy.logwarn('post tweet failed. status_code: {}'
.format(request.status_code))
if 'errors' in data:
for error in data['errors']:
rospy.logwarn('Tweet error code: {}, message: {}'
.format(error['code'], error['message']))
valid = False
else:
rospy.logwarn('post tweet failed. status_code: {}'
.format(request.status_code))
valid = False
if valid:
return data
Expand Down

0 comments on commit 30faf99

Please sign in to comment.