From 6125fb160e6285e564b38a9135e492e1721c37c9 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 11 Nov 2023 18:59:06 +0900 Subject: [PATCH] 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. --- cli/src/cli_util.rs | 2 +- lib/src/op_store.rs | 8 ++++++-- lib/src/simple_op_store.rs | 6 +++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 6ddfd9720..d93a78c26 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -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) => { diff --git a/lib/src/op_store.rs b/lib/src/op_store.rs index 5660ba7c9..ed545895d 100644 --- a/lib/src/op_store.rs +++ b/lib/src/op_store.rs @@ -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, + }, #[error("Error when reading object {hash} of type {object_type}: {source}")] ReadObject { object_type: String, diff --git a/lib/src/simple_op_store.rs b/lib/src/simple_op_store.rs index 74147dfb2..453098989 100644 --- a/lib/src/simple_op_store.rs +++ b/lib/src/simple_op_store.rs @@ -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(),