Skip to content

Commit

Permalink
Add a string payload to RepoError::Incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjg committed Dec 8, 2023
1 parent 7ecbdf0 commit a858e60
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub enum RepoError {
/// The repo is shutting down.
Shutdown,
/// Incorrect use of API. TODO: specify.
Incorrect,
Incorrect(String),
/// Error coming from storage.
StorageError(StorageError),
}
Expand Down Expand Up @@ -683,8 +683,12 @@ impl DocumentInfo {
let mut doc = self.document.write();
doc.automerge.load_incremental(&val)
};
if res.is_err() {
self.state.resolve_load_fut(Err(RepoError::Incorrect));
if let Err(e) = res {
self.state
.resolve_load_fut(Err(RepoError::Incorrect(format!(
"error loading document: {:?}",
e
))));
self.state = DocState::Error;
return;
}
Expand Down Expand Up @@ -720,8 +724,12 @@ impl DocumentInfo {
let mut doc = self.document.write();
doc.automerge.load_incremental(&val)
};
if res.is_err() {
self.state.resolve_bootstrap_fut(Err(RepoError::Incorrect));
if let Err(e) = res {
self.state
.resolve_bootstrap_fut(Err(RepoError::Incorrect(format!(
"error loading document: {:?}",
e
))));
self.state = DocState::Error;
return;
}
Expand Down Expand Up @@ -1334,7 +1342,8 @@ impl Repo {
);
info.state.resolve_bootstrap_fut(Ok(handle));
} else {
info.state.resolve_bootstrap_fut(Err(RepoError::Incorrect));
tracing::warn!(state=?info.state, "newdoc event received for existing document with incorrect state");
info.state.resolve_bootstrap_fut(Err(RepoError::Incorrect(format!("newdoc event received for existing document with incorrect state: {:?}", info.state))));
}
return;
} else {
Expand Down

0 comments on commit a858e60

Please sign in to comment.