From d91c3450a11c097d34ceba4444758fffe815b61a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 7 Apr 2015 14:05:12 +0300 Subject: [PATCH] Include filename in errors from stat --- source/fs/unix/stat.cpp | 11 +++++++---- source/fs/windows/stat.cpp | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/source/fs/unix/stat.cpp b/source/fs/unix/stat.cpp index 1ba62cd..3523633 100644 --- a/source/fs/unix/stat.cpp +++ b/source/fs/unix/stat.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "stat.h" #include "stat_private.h" @@ -47,10 +48,11 @@ Stat Stat::stat(const Path &path) int ret = ::stat(path.str().c_str(), &st); if(ret==-1) { - if(errno==ENOENT) + int err = errno; + if(err==ENOENT) return Stat(); else - throw system_error("stat"); + throw system_error(format("stat(%s)", path), err); } return Private::from_struct_stat(st); @@ -62,10 +64,11 @@ Stat Stat::lstat(const Path &path) int ret = ::lstat(path.str().c_str(), &st); if(ret==-1) { - if(errno==ENOENT) + int err = errno; + if(err==ENOENT) return Stat(); else - throw system_error("lstat"); + throw system_error(format("lstat(%s)", path), err); } return Private::from_struct_stat(st); diff --git a/source/fs/windows/stat.cpp b/source/fs/windows/stat.cpp index 229d9e9..a1f19ef 100644 --- a/source/fs/windows/stat.cpp +++ b/source/fs/windows/stat.cpp @@ -80,7 +80,7 @@ Stat Stat::stat(const Path &path) if(err==ERROR_FILE_NOT_FOUND) return Stat(); else - throw system_error("CreateFile", err); + throw system_error(format("CreateFile(%s)", path), err); } BY_HANDLE_FILE_INFORMATION info; -- 2.43.0