@@ -112,7 +112,7 @@ impl<'a> InteractivePrinter<'a> {
112 assets: &'a HighlightingAssets,
112 assets: &'a HighlightingAssets,
113 input: &mut OpenedInput,
113 input: &mut OpenedInput,
114 #[cfg(feature = "git")] line_changes: &'a Option<LineChanges>,
114 #[cfg(feature = "git")] line_changes: &'a Option<LineChanges>,
115− ) -> Self {
115+ ) -> Result<Self> {
116 let theme = assets.get_theme(&config.theme);
116 let theme = assets.get_theme(&config.theme);
118 let background_color_highlight = theme.settings.line_highlight;
118 let background_color_highlight = theme.settings.line_highlight;
@@ -164,14 +164,18 @@ impl<'a> InteractivePrinter<'a> {
166 // Determine the type of syntax for highlighting
166 // Determine the type of syntax for highlighting
168− .get_syntax(config.language, input, &config.syntax_mapping)
167+ let syntax = match assets.get_syntax(config.language, input, &config.syntax_mapping) {
168+ Ok(syntax) => syntax,
169+ Err(Error(ErrorKind::UndetectedSyntax(_), _)) => {
169− .unwrap_or_else(|_| assets.syntax_set.find_syntax_plain_text());
170+ assets.syntax_set.find_syntax_plain_text()
172+ Err(e) => return Err(e),
171 Some(HighlightLines::new(syntax, theme))
175 Some(HighlightLines::new(syntax, theme))
174− InteractivePrinter {
178+ Ok(InteractivePrinter {
175 panel_width,
179 panel_width,
@@ -183,7 +187,7 @@ impl<'a> InteractivePrinter<'a> {
183 highlighter,
187 highlighter,
184 syntax_set: &assets.syntax_set,
188 syntax_set: &assets.syntax_set,
185 background_color_highlight,
189 background_color_highlight,
189 fn print_horizontal_line(&mut self, handle: &mut dyn Write, grid_char: char) -> Result<()> {
193 fn print_horizontal_line(&mut self, handle: &mut dyn Write, grid_char: char) -> Result<()> {