ok/jj
1
0
Fork 0
forked from mirrors/jj

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.
This commit is contained in:
Yuya Nishihara 2024-02-27 21:22:39 +09:00
parent 26c182a0b0
commit aa79582092

View file

@ -415,8 +415,7 @@ impl<C, T: Template<C>> TemplateProperty<C> for PlainTextFormattedProperty<T> {
self.template self.template
.format(context, &mut PlainTextFormatter::new(&mut output)) .format(context, &mut PlainTextFormatter::new(&mut output))
.expect("write() to PlainTextFormatter should never fail"); .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).map_err(|err| err.utf8_error())?)
Ok(String::from_utf8(output).expect("template output should be utf-8 bytes"))
} }
} }