From 12400210a2ba16370914811c24fbe700e4eecc03 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Sat, 16 Feb 2019 09:42:00 +0100 Subject: [PATCH] tools::file_get_contents - improve error message --- src/tools.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tools.rs b/src/tools.rs index 92261429..55657599 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -104,8 +104,13 @@ pub fn file_read_firstline>(path: P) -> Result { }).map_err(|err: Error| format_err!("unable to read {:?} - {}", path, err)) } -pub fn file_get_contents>(path: P) -> Result, std::io::Error> { - std::fs::read(path) +pub fn file_get_contents>(path: P) -> Result, Error> { + + let path = path.as_ref(); + + try_block!({ + std::fs::read(path) + }).map_err(|err| format_err!("unable to read {:?} - {}", path, err)) } /// Atomically write a file. We first create a temporary file, which