about summary refs log tree commit diff
path: root/tvix/store/src/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/store/src/errors.rs')
-rw-r--r--tvix/store/src/errors.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/tvix/store/src/errors.rs b/tvix/store/src/errors.rs
index 7f74744284..25e87c8aa2 100644
--- a/tvix/store/src/errors.rs
+++ b/tvix/store/src/errors.rs
@@ -1,5 +1,6 @@
 use std::sync::PoisonError;
 use thiserror::Error;
+use tonic::Status;
 
 /// Errors related to communication with the store.
 #[derive(Debug, Error)]
@@ -16,3 +17,12 @@ impl<T> From<PoisonError<T>> for Error {
         Error::StorageError(value.to_string())
     }
 }
+
+impl From<Error> for Status {
+    fn from(value: Error) -> Self {
+        match value {
+            Error::InvalidRequest(msg) => Status::invalid_argument(msg),
+            Error::StorageError(msg) => Status::data_loss(format!("storage error: {}", msg)),
+        }
+    }
+}