Add filtered deck error localisation on backend
This commit is contained in:
parent
1dca43f409
commit
ef925a88d6
@ -1,5 +1,4 @@
|
|||||||
errors-invalid-deck-name = Invalid deck name: { $reason }
|
|
||||||
errors-invalid-input-empty = Invalid input.
|
errors-invalid-input-empty = Invalid input.
|
||||||
errors-invalid-input-details = Invalid input: { $details }
|
errors-invalid-input-details = Invalid input: { $details }
|
||||||
errors-parse-number-fail = A number was invalid or out of range.
|
errors-parse-number-fail = A number was invalid or out of range.
|
||||||
errors-reason-filtered-parent = Filtered decks cannot be parent decks.
|
errors-filtered-parent-deck = Invalid deck name: Filtered decks cannot be parent decks.
|
||||||
|
@ -47,7 +47,15 @@ class ExistsError(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class DeckIsFilteredError(Exception):
|
class DeckRenameError(Exception):
|
||||||
|
"""Legacy error, use DeckIsFilteredError instead."""
|
||||||
|
|
||||||
|
def __init__(self, description: str, *args: object) -> None:
|
||||||
|
super().__init__(description, *args)
|
||||||
|
self.description = description
|
||||||
|
|
||||||
|
|
||||||
|
class DeckIsFilteredError(StringError, DeckRenameError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@ -78,7 +86,7 @@ def backend_exception_to_pylib(err: _pb.BackendError) -> Exception:
|
|||||||
elif val == "exists":
|
elif val == "exists":
|
||||||
return ExistsError()
|
return ExistsError()
|
||||||
elif val == "deck_is_filtered":
|
elif val == "deck_is_filtered":
|
||||||
return DeckIsFilteredError()
|
return DeckIsFilteredError(err.localized)
|
||||||
elif val == "proto_error":
|
elif val == "proto_error":
|
||||||
return StringError(err.localized)
|
return StringError(err.localized)
|
||||||
else:
|
else:
|
||||||
@ -95,12 +103,3 @@ class AnkiError(Exception):
|
|||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.type
|
return self.type
|
||||||
|
|
||||||
|
|
||||||
class DeckRenameError(Exception):
|
|
||||||
def __init__(self, description: str) -> None:
|
|
||||||
super().__init__()
|
|
||||||
self.description = description
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
|
||||||
return f"Couldn't rename deck: {self.description}"
|
|
||||||
|
@ -208,6 +208,7 @@ impl AnkiError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
AnkiError::ParseNumError => i18n.tr(TR::ErrorsParseNumberFail).into(),
|
AnkiError::ParseNumError => i18n.tr(TR::ErrorsParseNumberFail).into(),
|
||||||
|
AnkiError::DeckIsFiltered => i18n.tr(TR::ErrorsFilteredParentDeck).into(),
|
||||||
_ => format!("{:?}", self),
|
_ => format!("{:?}", self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user