Merge pull request #1168 from RumovZ/fix-regex-err

Fix regex error formatting
This commit is contained in:
Damien Elmes 2021-05-17 10:08:55 +10:00 committed by GitHub
commit 958823fd6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 4 deletions

View file

@ -75,6 +75,7 @@ impl AnkiError {
} }
AnkiError::ParseNumError => tr.errors_parse_number_fail().into(), AnkiError::ParseNumError => tr.errors_parse_number_fail().into(),
AnkiError::FilteredDeckError(err) => err.localized_description(tr), AnkiError::FilteredDeckError(err) => err.localized_description(tr),
AnkiError::InvalidRegex(err) => format!("<pre>{}</pre>", err),
_ => format!("{:?}", self), _ => format!("{:?}", self),
} }
} }

View file

@ -34,7 +34,6 @@ pub enum SearchErrorKind {
InvalidPositiveWholeNumber { provided: String, context: String }, InvalidPositiveWholeNumber { provided: String, context: String },
InvalidNegativeWholeNumber { provided: String, context: String }, InvalidNegativeWholeNumber { provided: String, context: String },
InvalidAnswerButton { provided: String, context: String }, InvalidAnswerButton { provided: String, context: String },
Regex(String),
Other(Option<String>), Other(Option<String>),
} }
@ -96,9 +95,6 @@ impl SearchErrorKind {
SearchErrorKind::InvalidPropOperator(ctx) => { SearchErrorKind::InvalidPropOperator(ctx) => {
tr.search_invalid_prop_operator(ctx.as_str()) tr.search_invalid_prop_operator(ctx.as_str())
} }
SearchErrorKind::Regex(text) => {
format!("<pre>`{}`</pre>", text.replace('`', "'")).into()
}
SearchErrorKind::Other(Some(info)) => info.into(), SearchErrorKind::Other(Some(info)) => info.into(),
SearchErrorKind::Other(None) => tr.search_invalid_other(), SearchErrorKind::Other(None) => tr.search_invalid_other(),
SearchErrorKind::InvalidNumber { provided, context } => { SearchErrorKind::InvalidNumber { provided, context } => {