diff options
author | Florian Klink <flokli@flokli.de> | 2023-09-23T08·48+0300 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2023-09-23T12·54+0000 |
commit | 09a901de5bde8a583d50fe4086c5128c6c0114c7 (patch) | |
tree | d485e31bc7957644cb2364abfefc6057f16c1c1f /tvix/nix-compat/src/store_path/mod.rs | |
parent | 8de0d6ad48a4974abc1cd22300e982dd2dab72a7 (diff) |
feat(tvix/nix-compat): fix and improve error message r/6638
Similar to cl/9350. Most of the times, this is still a regular string, so let's print it like that if we can, and resort to base64 encoding if we can't. We were also wrongly always outputting the second character in the string. Change-Id: Id0e2a9d9f1ad3d2d7b554893ecd89a7e6383e9c2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9445 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/nix-compat/src/store_path/mod.rs')
-rw-r--r-- | tvix/nix-compat/src/store_path/mod.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tvix/nix-compat/src/store_path/mod.rs b/tvix/nix-compat/src/store_path/mod.rs index 0ed6b2ba0754..e9e2978b7cc8 100644 --- a/tvix/nix-compat/src/store_path/mod.rs +++ b/tvix/nix-compat/src/store_path/mod.rs @@ -1,4 +1,5 @@ use crate::nixbase32::{self, Nixbase32DecodeError}; +use data_encoding::BASE64; use std::{fmt, path::PathBuf, str::FromStr}; use thiserror; @@ -28,7 +29,11 @@ pub enum Error { InvalidHashEncoding(Nixbase32DecodeError), #[error("Invalid length")] InvalidLength(), - #[error("Invalid name: {:?}, character at position {} ('{}') is invalid", .0, .1, .0[1])] + #[error( + "Invalid name: \"{}\", character at position {} is invalid", + std::str::from_utf8(&.0).unwrap_or(&BASE64.encode(.0)), + .1, + )] InvalidName(Vec<u8>, usize), #[error("Tried to parse an absolute path which was missing the store dir prefix.")] MissingStoreDir(), |