feat(tvix/store): improve error message formatting
WrongSorting(Vec<u8>) actually encodes the name of a node, so if we can, we want this to display it as a string (and fall back to the base64 encoding if we can't). Before: > rpc error: code = InvalidArgument desc = directory b3:yfwNlpPm8MkrRvshGHfgMtKLoSDtX2pKliVuVWmUt5g= failed validation: [108, 111, 99, 97, 108, 101] is not sorted After: > rpc error: code = InvalidArgument desc = directory b3:yfwNlpPm8MkrRvshGHfgMtKLoSDtX2pKliVuVWmUt5g= failed validation: locale is not sorted Change-Id: I68420c53a89cb1aa96e4bdce414366cebcb7915f Reviewed-on: https://cl.tvl.fyi/c/depot/+/9350 Tested-by: BuildkiteCI Reviewed-by: Connor Brewster <cbrewster@hey.com> Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
parent
54bb63dea3
commit
51b8571c48
1 changed files with 2 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
#![allow(clippy::derive_partial_eq_without_eq, non_snake_case)]
|
||||
// https://github.com/hyperium/tonic/issues/1056
|
||||
use data_encoding::BASE64;
|
||||
use std::{collections::HashSet, iter::Peekable};
|
||||
use thiserror::Error;
|
||||
|
||||
|
@ -34,7 +35,7 @@ mod tests;
|
|||
#[derive(Debug, PartialEq, Eq, Error)]
|
||||
pub enum ValidateDirectoryError {
|
||||
/// Elements are not in sorted order
|
||||
#[error("{0:?} is not sorted")]
|
||||
#[error("{} is not sorted", std::str::from_utf8(.0).unwrap_or(&BASE64.encode(.0)))]
|
||||
WrongSorting(Vec<u8>),
|
||||
/// Multiple elements with the same name encountered
|
||||
#[error("{0:?} is a duplicate name")]
|
||||
|
|
Loading…
Reference in a new issue