mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 23:42:23 -04:00
convert card template error to tuple, and report notetype name in error
Older translations will note have the $notetype variable, but that is not an error in Fluent - it would only cause problems if we tried to use the new string on older Anki versions.
This commit is contained in:
parent
7a29d987c4
commit
ba541076aa
3 changed files with 15 additions and 6 deletions
|
@ -18,7 +18,7 @@ card-templates-night-mode = Night Mode
|
||||||
# on a mobile device.
|
# on a mobile device.
|
||||||
card-templates-add-mobile-class = Add Mobile Class
|
card-templates-add-mobile-class = Add Mobile Class
|
||||||
card-templates-preview-settings = Options
|
card-templates-preview-settings = Options
|
||||||
card-templates-invalid-template-number = Card template { $number } has a problem.
|
card-templates-invalid-template-number = Card template { $number } in notetype '{ $notetype }' has a problem.
|
||||||
card-templates-changes-saved = Changes saved.
|
card-templates-changes-saved = Changes saved.
|
||||||
card-templates-discard-changes = Discard changes?
|
card-templates-discard-changes = Discard changes?
|
||||||
card-templates-add-card-type = Add Card Type...
|
card-templates-add-card-type = Add Card Type...
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub type Result<T, E = AnkiError> = std::result::Result<T, E>;
|
||||||
pub enum AnkiError {
|
pub enum AnkiError {
|
||||||
InvalidInput(String),
|
InvalidInput(String),
|
||||||
TemplateError(String),
|
TemplateError(String),
|
||||||
TemplateSaveError { ordinal: usize },
|
TemplateSaveError(TemplateSaveError),
|
||||||
IoError(String),
|
IoError(String),
|
||||||
DbError(DbError),
|
DbError(DbError),
|
||||||
NetworkError(NetworkError),
|
NetworkError(NetworkError),
|
||||||
|
@ -60,8 +60,8 @@ impl AnkiError {
|
||||||
// already localized
|
// already localized
|
||||||
info.into()
|
info.into()
|
||||||
}
|
}
|
||||||
AnkiError::TemplateSaveError { ordinal } => tr
|
AnkiError::TemplateSaveError(err) => tr
|
||||||
.card_templates_invalid_template_number(ordinal + 1)
|
.card_templates_invalid_template_number(err.ordinal + 1, &err.notetype)
|
||||||
.into(),
|
.into(),
|
||||||
AnkiError::DbError(err) => err.localized_description(tr),
|
AnkiError::DbError(err) => err.localized_description(tr),
|
||||||
AnkiError::SearchError(kind) => kind.localized_description(&tr),
|
AnkiError::SearchError(kind) => kind.localized_description(&tr),
|
||||||
|
@ -129,3 +129,9 @@ impl From<regex::Error> for AnkiError {
|
||||||
AnkiError::InvalidRegex(err.to_string())
|
AnkiError::InvalidRegex(err.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct TemplateSaveError {
|
||||||
|
pub notetype: String,
|
||||||
|
pub ordinal: usize,
|
||||||
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ use crate::{
|
||||||
collection::Collection,
|
collection::Collection,
|
||||||
decks::DeckId,
|
decks::DeckId,
|
||||||
define_newtype,
|
define_newtype,
|
||||||
error::{AnkiError, Result},
|
error::{AnkiError, Result, TemplateSaveError},
|
||||||
notes::Note,
|
notes::Note,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
template::{FieldRequirements, ParsedTemplate},
|
template::{FieldRequirements, ParsedTemplate},
|
||||||
|
@ -250,7 +250,10 @@ impl Notetype {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if let Some(idx) = invalid_card_idx {
|
if let Some(idx) = invalid_card_idx {
|
||||||
return Err(AnkiError::TemplateSaveError { ordinal: idx });
|
return Err(AnkiError::TemplateSaveError(TemplateSaveError {
|
||||||
|
notetype: self.name.clone(),
|
||||||
|
ordinal: idx,
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
let reqs = self.updated_requirements(&parsed_templates);
|
let reqs = self.updated_requirements(&parsed_templates);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue