diff --git a/rslib/src/backend/err.rs b/rslib/src/backend/err.rs index 421e1238d..9882cc6c6 100644 --- a/rslib/src/backend/err.rs +++ b/rslib/src/backend/err.rs @@ -25,8 +25,8 @@ pub(super) fn anki_error_to_proto_error(err: AnkiError, tr: &I18n) -> pb::Backen AnkiError::Interrupted => V::Interrupted(pb::Empty {}), AnkiError::CollectionNotOpen => V::InvalidInput(pb::Empty {}), AnkiError::CollectionAlreadyOpen => V::InvalidInput(pb::Empty {}), - AnkiError::JsonError { info } => V::JsonError(info), - AnkiError::ProtoError { info } => V::ProtoError(info), + AnkiError::JsonError(info) => V::JsonError(info), + AnkiError::ProtoError(info) => V::ProtoError(info), AnkiError::NotFound => V::NotFoundError(pb::Empty {}), AnkiError::Existing => V::Exists(pb::Empty {}), AnkiError::DeckIsFiltered => V::DeckIsFiltered(pb::Empty {}), diff --git a/rslib/src/error/mod.rs b/rslib/src/error/mod.rs index 61d99fd80..a02893990 100644 --- a/rslib/src/error/mod.rs +++ b/rslib/src/error/mod.rs @@ -20,14 +20,14 @@ pub type Result = std::result::Result; #[derive(Debug, PartialEq)] pub enum AnkiError { InvalidInput(String), - TemplateError { info: String }, + TemplateError(String), TemplateSaveError { ordinal: usize }, IoError(String), DbError(DbError), NetworkError(NetworkError), SyncError(SyncError), - JsonError { info: String }, - ProtoError { info: String }, + JsonError(String), + ProtoError(String), ParseNumError, Interrupted, CollectionNotOpen, @@ -56,7 +56,7 @@ impl AnkiError { match self { AnkiError::SyncError(err) => err.localized_description(tr), AnkiError::NetworkError(err) => err.localized_description(tr), - AnkiError::TemplateError { info } => { + AnkiError::TemplateError(info) => { // already localized info.into() } @@ -102,25 +102,19 @@ impl From for AnkiError { impl From for AnkiError { fn from(err: serde_json::Error) -> Self { - AnkiError::JsonError { - info: err.to_string(), - } + AnkiError::JsonError(err.to_string()) } } impl From for AnkiError { fn from(err: prost::EncodeError) -> Self { - AnkiError::ProtoError { - info: err.to_string(), - } + AnkiError::ProtoError(err.to_string()) } } impl From for AnkiError { fn from(err: prost::DecodeError) -> Self { - AnkiError::ProtoError { - info: err.to_string(), - } + AnkiError::ProtoError(err.to_string()) } } diff --git a/rslib/src/template.rs b/rslib/src/template.rs index 7b1ae0dca..5f7359004 100644 --- a/rslib/src/template.rs +++ b/rslib/src/template.rs @@ -259,7 +259,7 @@ fn template_error_to_anki_error(err: TemplateError, q_side: bool, tr: &I18n) -> header, details, TEMPLATE_ERROR_LINK, more_info ); - AnkiError::TemplateError { info } + AnkiError::TemplateError(info) } fn localized_template_error(tr: &I18n, err: TemplateError) -> String {