mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 07:52:24 -04:00
add separate json error
This commit is contained in:
parent
03db16460a
commit
75faba1667
3 changed files with 8 additions and 1 deletions
|
@ -131,6 +131,7 @@ message BackendError {
|
|||
SyncError sync_error = 7;
|
||||
// user interrupted operation
|
||||
Empty interrupted = 8;
|
||||
string json_error = 9;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,7 @@ fn anki_error_to_proto_error(err: AnkiError, i18n: &I18n) -> pb::BackendError {
|
|||
AnkiError::CollectionNotOpen => V::InvalidInput(pb::Empty {}),
|
||||
AnkiError::CollectionAlreadyOpen => V::InvalidInput(pb::Empty {}),
|
||||
AnkiError::SchemaChange => V::InvalidInput(pb::Empty {}),
|
||||
AnkiError::JSONError { info } => V::JsonError(info),
|
||||
};
|
||||
|
||||
pb::BackendError {
|
||||
|
|
|
@ -31,6 +31,9 @@ pub enum AnkiError {
|
|||
#[fail(display = "Sync error: {:?}, {}", kind, info)]
|
||||
SyncError { info: String, kind: SyncErrorKind },
|
||||
|
||||
#[fail(display = "JSON encode/decode error: {}", info)]
|
||||
JSONError { info: String },
|
||||
|
||||
#[fail(display = "The user interrupted the operation.")]
|
||||
Interrupted,
|
||||
|
||||
|
@ -223,7 +226,9 @@ impl From<zip::result::ZipError> for AnkiError {
|
|||
|
||||
impl From<serde_json::Error> for AnkiError {
|
||||
fn from(err: serde_json::Error) -> Self {
|
||||
AnkiError::sync_misc(err.to_string())
|
||||
AnkiError::JSONError {
|
||||
info: err.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue