mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-05 20:55:05 +00:00
op_store: embed details in operation/view not found error
This is basically a copy of BackendError::ObjectNotFound. The failed id may be either view or operation id.
This commit is contained in:
parent
ea96513fd1
commit
6125fb160e
3 changed files with 12 additions and 4 deletions
|
@ -1958,7 +1958,7 @@ fn resolve_single_op_from_store(
|
|||
Ok(operation) => {
|
||||
return Ok(Operation::new(op_store.clone(), op_id, operation));
|
||||
}
|
||||
Err(OpStoreError::NotFound) => {
|
||||
Err(OpStoreError::ObjectNotFound { .. }) => {
|
||||
// Fall through
|
||||
}
|
||||
Err(err) => {
|
||||
|
|
|
@ -384,8 +384,12 @@ content_hash! {
|
|||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum OpStoreError {
|
||||
#[error("Operation not found")]
|
||||
NotFound,
|
||||
#[error("Object {hash} of type {object_type} not found: {source}")]
|
||||
ObjectNotFound {
|
||||
object_type: String,
|
||||
hash: String,
|
||||
source: Box<dyn std::error::Error + Send + Sync>,
|
||||
},
|
||||
#[error("Error when reading object {hash} of type {object_type}: {source}")]
|
||||
ReadObject {
|
||||
object_type: String,
|
||||
|
|
|
@ -155,7 +155,11 @@ impl OpStore for SimpleOpStore {
|
|||
|
||||
fn io_to_read_error(err: std::io::Error, id: &impl ObjectId) -> OpStoreError {
|
||||
if err.kind() == ErrorKind::NotFound {
|
||||
OpStoreError::NotFound
|
||||
OpStoreError::ObjectNotFound {
|
||||
object_type: id.object_type(),
|
||||
hash: id.hex(),
|
||||
source: Box::new(err),
|
||||
}
|
||||
} else {
|
||||
OpStoreError::ReadObject {
|
||||
object_type: id.object_type(),
|
||||
|
|
Loading…
Reference in a new issue