Skip to content

Commit

Permalink
Timestamp non-specific Exceptions in connection records
Browse files Browse the repository at this point in the history
  • Loading branch information
cpfair committed Feb 25, 2016
1 parent e74f55b commit 1de30ea
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tapiriik/sync/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def _packServiceException(step, e):
res["UserException"] = _packUserException(e.UserException)
return res

def _packException(step):
return {"Step": step, "Message": _formatExc(), "Timestamp": datetime.utcnow()}

def _packUserException(userException):
if userException:
return {"Type": userException.Type, "Extra": userException.Extra, "InterventionRequired": userException.InterventionRequired, "ClearGroup": userException.ClearGroup}
Expand Down Expand Up @@ -643,7 +646,7 @@ def _downloadActivityList(self, conn, exhaustive, no_add=False):
if not _isWarning(e):
return
except Exception as e:
self._syncErrors[conn._id].append({"Step": SyncStep.List, "Message": _formatExc()})
self._syncErrors[conn._id].append(_packException(SyncStep.List))
self._excludeService(conn, UserException(UserExceptionType.ListingError))
return
self._accumulateExclusions(conn, svcExclusions)
Expand Down Expand Up @@ -761,7 +764,7 @@ def _downloadActivity(self, activity):
activity.Record.MarkAsNotPresentOtherwise(e.UserException)
continue
except Exception as e:
packed_exc = {"Step": SyncStep.Download, "Message": _formatExc()}
packed_exc = _packException(SyncStep.Download)

activity.Record.IncrementFailureCount(dlSvcRecord)
if activity.Record.GetFailureCount(dlSvcRecord) >= dlSvc.DownloadRetryCount:
Expand Down Expand Up @@ -814,7 +817,7 @@ def _uploadActivity(self, activity, destinationServiceRec):
activity.Record.MarkAsNotPresentOn(destinationServiceRec, e.UserException if e.UserException else UserException(UserExceptionType.UploadError))
raise UploadException()
except Exception as e:
packed_exc = {"Step": SyncStep.Upload, "Message": _formatExc()}
packed_exc = _packException(SyncStep.Upload)

activity.Record.IncrementFailureCount(destinationServiceRec)
if activity.Record.GetFailureCount(destinationServiceRec) >= destSvc.UploadRetryCount:
Expand Down

0 comments on commit 1de30ea

Please sign in to comment.