From 68e473ed6b918df8dba800aa8ae0e01543be4049 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 18 Nov 2023 18:30:55 +0200 Subject: feat(tvix/castore): impl From for Error 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 Reviewed-by: flokli Autosubmit: flokli Tested-by: BuildkiteCI --- tvix/castore/src/errors.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tvix/castore') 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 for Error { } } +impl From 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 for std::io::Error { fn from(value: Error) -> Self { -- cgit 1.4.1