anki/pylib/anki
RumovZ c521753057
Refactor error handling (#2136)
* Add crate snafu

* Replace all inline structs in AnkiError

* Derive Snafu on AnkiError

* Use snafu for card type errors

* Use snafu whatever error for InvalidInput

* Use snafu for NotFoundError and improve message

* Use snafu for FileIoError to attach context

Remove IoError.
Add some context-attaching helpers to replace code returning bare
io::Errors.

* Add more context-attaching io helpers

* Add message, context and backtrace to new snafus

* Utilize error context and backtrace on frontend

* Rename LocalizedError -> BackendError.
* Remove DocumentedError.
* Have all backend exceptions inherit BackendError.

* Rename localized(_description) -> message

* Remove accidentally committed experimental trait

* invalid_input_context -> ok_or_invalid

* ensure_valid_input! -> require!

* Always return `Err` from `invalid_input!`

Instead of a Result to unwrap, the macro accepts a source error now.

* new_tempfile_in_parent -> new_tempfile_in_parent_of

* ok_or_not_found -> or_not_found

* ok_or_invalid -> or_invalid

* Add crate convert_case

* Use unqualified lowercase type name

* Remove uses of snafu::ensure

* Allow public construction of InvalidInputErrors (dae)

Needed to port the AnkiDroid changes.

* Make into_protobuf() public (dae)

Also required for AnkiDroid. Not sure why it worked previously - possible
bug in older Rust version?
2022-10-21 18:02:12 +10:00
..
_backend Refactor error handling (#2136) 2022-10-21 18:02:12 +10:00
_vendor PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
foreign_data Plaintext import/export (#1850) 2022-06-01 20:26:16 +10:00
importing Update Python deps 2022-09-24 09:46:43 +10:00
scheduler Enable state-dependent custom scheduling data (#2049) 2022-09-05 16:48:01 +10:00
syncserver updated package scripts 2021-10-28 18:46:45 +10:00
__init__.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
_legacy.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
backend_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
browser.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
BUILD.bazel add missing wheel/helper for darwin-arm64 2021-10-28 18:29:18 +10:00
buildinfo.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
card_rendering_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
cards_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
cards.py Add card meta for persisting custom scheduling state (#2040) 2022-09-02 11:22:49 +10:00
collection_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
collection.py Update Python deps 2022-09-24 09:46:43 +10:00
config_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
config.py Import submodules directly (#1662) 2022-02-13 13:40:47 +10:00
consts.py Plaintext import/export (#1850) 2022-06-01 20:26:16 +10:00
db.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
dbproxy.py fix cyclic import when importing anki.collection directly 2022-02-15 19:08:29 +10:00
deckconfig_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
decks_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
decks.py Add non-legacy backend interface for adding new decks 2022-09-04 14:12:29 +10:00
errors.py Refactor error handling (#2136) 2022-10-21 18:02:12 +10:00
exporting.py Narrow typehints within pylib (#2003) 2022-08-05 14:48:07 +10:00
find.py Add py3.9 to hooks (#1542) 2021-12-09 09:11:22 +10:00
generic_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
hooks_gen.py fix generated code symlinks again 2022-01-24 16:59:37 +10:00
hooks.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
httpclient.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
i18n_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
import_export_pb2.pyi Add apkg import/export on backend (#1743) 2022-05-02 21:12:46 +10:00
lang.py add Odia to language list 2022-02-07 22:31:41 +10:00
latex.py Make dvipng use transparent background by default (#2036) 2022-08-31 18:49:22 +10:00
links_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
media_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
media.py Narrow typehints within pylib (#2003) 2022-08-05 14:48:07 +10:00
models.py Import submodules directly (#1662) 2022-02-13 13:40:47 +10:00
notes_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
notes.py Narrow typehints within pylib (#2003) 2022-08-05 14:48:07 +10:00
notetypes_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
py.typed mark anki and aqt modules as having typing info 2020-01-13 13:03:37 +10:00
rsbackend.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
scheduler_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
search_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
sound.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
stats_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
stats.py Add back support for custom mountpoint in card stats 2022-04-15 15:30:05 +10:00
statsbg.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
stdmodels.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
storage.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
sync_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
sync.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
tags_pb2.pyi fix generated code symlinks again 2022-01-24 16:59:37 +10:00
tags.py Move custom study tag and limit gathering+saving into the backend 2022-03-10 16:23:03 +10:00
template.py Store rendered side in TemplateRenderContext (#1852) 2022-05-10 11:44:44 +10:00
types.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
utils.py Update Python deps 2022-09-24 09:46:43 +10:00
wheel_description.txt move aqt_data into source folder; implement wheel building 2020-11-04 12:14:03 +10:00