From aa795820923c07ce28e72c507aa113cdf2889627 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Tue, 27 Feb 2024 21:22:39 +0900 Subject: [PATCH] templater: translate UTF-8 conversion error to runtime error This isn't a problem as of now, but we'll probably add commit.diff() or something later. --- cli/src/templater.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cli/src/templater.rs b/cli/src/templater.rs index 24a8e84b2..0b6a5c2e3 100644 --- a/cli/src/templater.rs +++ b/cli/src/templater.rs @@ -415,8 +415,7 @@ impl> TemplateProperty for PlainTextFormattedProperty { self.template .format(context, &mut PlainTextFormatter::new(&mut output)) .expect("write() to PlainTextFormatter should never fail"); - // TODO: Use from_utf8_lossy() if we added template that embeds file content - Ok(String::from_utf8(output).expect("template output should be utf-8 bytes")) + Ok(String::from_utf8(output).map_err(|err| err.utf8_error())?) } }