Skip to content

Commit 116f68b

Browse files
Update error handling a little.
1 parent 143d20c commit 116f68b

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

source/oneWaySync.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,25 @@ def get_tasks(token):
8787
new_hab = main.make_hab_from_tod(tod)
8888
newDict = new_hab.task_dict
8989
r = main.write_hab_task(newDict)
90-
print("Added hab to %s!" % tod.name)
91-
print(r)
9290
if r.ok == False:
93-
fin_hab = main.get_hab_fromID(tid)
91+
errMsg = r.json()['errors'][0]['message']
92+
alias = r.json()['errors'][0]['value']
93+
print("ERROR: Code: "+str(r.status_code)+", Error message: \""
94+
+errMsg+"\", Task alias: "+alias)
9495
else:
96+
print("Added hab to %s!" % tod.name)
9597
fin_hab = main.get_hab_fromID(tid)
96-
matchDict[tid] = {}
97-
matchDict[tid]['tod'] = tod
98-
matchDict[tid]['hab'] = fin_hab
99-
matchDict[tid]['recurs'] = tod.recurring
100-
if matchDict[tid]['recurs'] == 'Yes':
101-
if tod.dueToday == 'Yes':
102-
matchDict[tid]['duelast'] = 'Yes'
98+
matchDict[tid] = {}
99+
matchDict[tid]['tod'] = tod
100+
matchDict[tid]['hab'] = fin_hab
101+
matchDict[tid]['recurs'] = tod.recurring
102+
if matchDict[tid]['recurs'] == 'Yes':
103+
if tod.dueToday == 'Yes':
104+
matchDict[tid]['duelast'] = 'Yes'
105+
else:
106+
matchDict[tid]['duelast'] = 'No'
103107
else:
104-
matchDict[tid]['duelast'] = 'No'
105-
else:
106-
matchDict[tid]['duelast'] = 'NA'
108+
matchDict[tid]['duelast'] = 'NA'
107109

108110
#Check that anything which has recently been completed gets updated in habitica
109111
for tid in matchDict:

0 commit comments

Comments
 (0)