mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00

* TemplateSaveError -> CardTypeError * Don't show success tooltip if export fails * Attach help page to error Show help link if export fails due to card type error. * Add type (dae) * Add shared show_exception() (dae) - Use a shared routine for printing standard backend errors, so that we can take advantage of the help links in eg. the card layout screen as well. - The truthiness check on help in showInfo() would have ignored the enum 0 value. - Close the exporting dialog on a documented failure as well * Fix local variable help_page
105 lines
1.7 KiB
Python
105 lines
1.7 KiB
Python
# Copyright: Ankitects Pty Ltd and contributors
|
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
from __future__ import annotations
|
|
|
|
from enum import Enum
|
|
from typing import TYPE_CHECKING
|
|
|
|
if TYPE_CHECKING:
|
|
import anki.collection
|
|
|
|
|
|
class LocalizedError(Exception):
|
|
"An error with a localized description."
|
|
|
|
def __init__(self, localized: str) -> None:
|
|
self._localized = localized
|
|
super().__init__()
|
|
|
|
def __str__(self) -> str:
|
|
return self._localized
|
|
|
|
|
|
class DocumentedError(LocalizedError):
|
|
"""A localized error described in the manual."""
|
|
|
|
def __init__(self, localized: str, help_page: anki.collection.HelpPage.V) -> None:
|
|
self.help_page = help_page
|
|
super().__init__(localized)
|
|
|
|
|
|
class Interrupted(Exception):
|
|
pass
|
|
|
|
|
|
class NetworkError(LocalizedError):
|
|
pass
|
|
|
|
|
|
class SyncErrorKind(Enum):
|
|
AUTH = 1
|
|
OTHER = 2
|
|
|
|
|
|
class SyncError(LocalizedError):
|
|
def __init__(self, localized: str, kind: SyncErrorKind):
|
|
self.kind = kind
|
|
super().__init__(localized)
|
|
|
|
|
|
class BackendIOError(LocalizedError):
|
|
pass
|
|
|
|
|
|
class CustomStudyError(LocalizedError):
|
|
pass
|
|
|
|
|
|
class DBError(LocalizedError):
|
|
pass
|
|
|
|
|
|
class CardTypeError(DocumentedError):
|
|
pass
|
|
|
|
|
|
class TemplateError(LocalizedError):
|
|
pass
|
|
|
|
|
|
class NotFoundError(Exception):
|
|
pass
|
|
|
|
|
|
class DeletedError(LocalizedError):
|
|
pass
|
|
|
|
|
|
class ExistsError(Exception):
|
|
pass
|
|
|
|
|
|
class UndoEmpty(Exception):
|
|
pass
|
|
|
|
|
|
class FilteredDeckError(LocalizedError):
|
|
pass
|
|
|
|
|
|
class InvalidInput(LocalizedError):
|
|
pass
|
|
|
|
|
|
class SearchError(LocalizedError):
|
|
pass
|
|
|
|
|
|
class AbortSchemaModification(Exception):
|
|
pass
|
|
|
|
|
|
# legacy
|
|
DeckRenameError = FilteredDeckError
|
|
AnkiError = AbortSchemaModification
|