summaryrefslogtreecommitdiffstats
path: root/src/path_printer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/path_printer.rs')
-rw-r--r--src/path_printer.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/path_printer.rs b/src/path_printer.rs
index 324a27c4..6307c288 100644
--- a/src/path_printer.rs
+++ b/src/path_printer.rs
@@ -2,8 +2,11 @@ use std::io;
use std::path::Path;
use grep::printer::{ColorSpecs, PrinterPath};
+use snafu::ResultExt;
use termcolor::WriteColor;
+use crate::err::{self, Result};
+
/// A configuration for describing how paths should be written.
#[derive(Clone, Debug)]
struct Config {
@@ -87,7 +90,11 @@ pub struct PathPrinter<W> {
impl<W: WriteColor> PathPrinter<W> {
/// Write the given path to the underlying writer.
- pub fn write_path(&mut self, path: &Path) -> io::Result<()> {
+ pub fn write_path(&mut self, path: &Path) -> Result<()> {
+ self.write(path).eager_context(err::IO)
+ }
+
+ fn write(&mut self, path: &Path) -> io::Result<()> {
let ppath = PrinterPath::with_separator(path, self.config.separator);
if !self.wtr.supports_color() {
self.wtr.write_all(ppath.as_bytes())?;