about summary refs log tree commit diff
path: root/tvix/castore
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-11-18T16·30+0200
committerflokli <flokli@flokli.de>2023-11-18T19·23+0000
commit68e473ed6b918df8dba800aa8ae0e01543be4049 (patch)
tree26bde4056f0d0f4c36b64c7913564f807c72cdf5 /tvix/castore
parentebfe45625190f9920125aa82b1c6c0ec63abac0d (diff)
feat(tvix/castore): impl From<std::io::Error> for Error r/7026
Make it less annoying to convert from io::Error to this. We already have
one direction, doesn't hurt to have the other too.

Change-Id: I9fe2c6da608c9d54910ee8c397572aadb1d90d99
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10068
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/castore')
-rw-r--r--tvix/castore/src/errors.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/tvix/castore/src/errors.rs b/tvix/castore/src/errors.rs
index 4c164029aeec..1b3ae4d1c862 100644
--- a/tvix/castore/src/errors.rs
+++ b/tvix/castore/src/errors.rs
@@ -40,6 +40,16 @@ impl From<crate::tonic::Error> for Error {
     }
 }
 
+impl From<std::io::Error> for Error {
+    fn from(value: std::io::Error) -> Self {
+        if value.kind() == std::io::ErrorKind::InvalidInput {
+            Error::InvalidRequest(value.to_string())
+        } else {
+            Error::StorageError(value.to_string())
+        }
+    }
+}
+
 // TODO: this should probably go somewhere else?
 impl From<Error> for std::io::Error {
     fn from(value: Error) -> Self {