mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 16:02:23 -04:00
catch network errors
This commit is contained in:
parent
93c768cab9
commit
0c124188cd
1 changed files with 10 additions and 3 deletions
|
@ -21,6 +21,7 @@ from anki.rsbackend import (
|
||||||
MediaSyncProgress,
|
MediaSyncProgress,
|
||||||
MediaSyncRemovedFiles,
|
MediaSyncRemovedFiles,
|
||||||
MediaSyncUploaded,
|
MediaSyncUploaded,
|
||||||
|
NetworkError,
|
||||||
Progress,
|
Progress,
|
||||||
ProgressKind,
|
ProgressKind,
|
||||||
)
|
)
|
||||||
|
@ -28,7 +29,7 @@ from anki.types import assert_impossible
|
||||||
from anki.utils import intTime
|
from anki.utils import intTime
|
||||||
from aqt import gui_hooks
|
from aqt import gui_hooks
|
||||||
from aqt.qt import QDialog, QDialogButtonBox, QPushButton
|
from aqt.qt import QDialog, QDialogButtonBox, QPushButton
|
||||||
from aqt.utils import showInfo
|
from aqt.utils import showWarning
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
@ -40,7 +41,6 @@ class MediaSyncState:
|
||||||
removed_files: int = 0
|
removed_files: int = 0
|
||||||
|
|
||||||
|
|
||||||
# fixme: handle network errors
|
|
||||||
# fixme: abort when closing collection/app
|
# fixme: abort when closing collection/app
|
||||||
# fixme: shards
|
# fixme: shards
|
||||||
# fixme: concurrent modifications during upload step
|
# fixme: concurrent modifications during upload step
|
||||||
|
@ -151,9 +151,16 @@ class MediaSyncer:
|
||||||
if isinstance(exc, AnkiWebAuthFailed):
|
if isinstance(exc, AnkiWebAuthFailed):
|
||||||
self.mw.pm.set_sync_key(None)
|
self.mw.pm.set_sync_key(None)
|
||||||
self._log_and_notify(_("Authentication failed."))
|
self._log_and_notify(_("Authentication failed."))
|
||||||
showInfo(_("AnkiWeb ID or password was incorrect; please try again."))
|
showWarning(_("AnkiWeb ID or password was incorrect; please try again."))
|
||||||
elif isinstance(exc, Interrupted):
|
elif isinstance(exc, Interrupted):
|
||||||
self._log_and_notify(_("Media sync aborted."))
|
self._log_and_notify(_("Media sync aborted."))
|
||||||
|
elif isinstance(exc, NetworkError):
|
||||||
|
self._log_and_notify(_("Network error."))
|
||||||
|
showWarning(
|
||||||
|
_("Syncing failed; please check your internet connection.")
|
||||||
|
+ "\n\n"
|
||||||
|
+ _("Detailed error: {}").format(str(exc))
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
raise exc
|
raise exc
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue