From 94da170b3023c41afa1da78df6667fe6de0ab441 Mon Sep 17 00:00:00 2001 From: Austin Seipp Date: Wed, 4 Sep 2024 17:26:08 -0500 Subject: [PATCH] buck2_validation: tweak and slightly improve error message Previously, when using `ValidationInfo()` with a failure, it ends up turning out an awkward message that turns { "status": "failure", "message": "you failed the test!" } into "you failed the test!". After this patch, it comes out as: you failed the test! Which seems much more reasonable and easy to parse. It also gives the validation message more control over the punctuation. Signed-off-by: Austin Seipp --- app/buck2_validation/src/cached_validation_result.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/buck2_validation/src/cached_validation_result.rs b/app/buck2_validation/src/cached_validation_result.rs index ed2bed4cafe6..9a87e2a96d85 100644 --- a/app/buck2_validation/src/cached_validation_result.rs +++ b/app/buck2_validation/src/cached_validation_result.rs @@ -30,7 +30,7 @@ pub(crate) enum CachedValidationResultData { #[derive(buck2_error::Error, Debug, PartialEq, Allocative, Clone)] #[error( - "Validation for `{target}` failed:\n\n{}.\n\nFull validation result is located at: `{result_path}`", self.rendered_message() + "Validation for `{target}` failed:\n\n{}\n\nFull validation result is located at: `{result_path}`", self.rendered_message() )] pub(crate) struct ValidationFailedUserFacingError { target: BaseDeferredKey, @@ -42,7 +42,7 @@ impl ValidationFailedUserFacingError { pub(crate) fn rendered_message(&self) -> Cow { self.short_message.as_deref().map_or_else( || Cow::Borrowed("Diagnostic message is missing from validation result"), - |x| Cow::Owned(format!("\"{}\"", x)), + |x| Cow::Owned(format!("{}", x)), ) } }