Skip to content

Commit

Permalink
Merge pull request #668 from openzim/even_more_informative_file_openi…
Browse files Browse the repository at this point in the history
…ng_error

Even more informative error message
  • Loading branch information
kelson42 authored Feb 13, 2022
2 parents 71d25f9 + 3776b66 commit a12d14a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/fs_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <unistd.h>
#include <dirent.h>
#include <errno.h>
#include <string.h>

namespace zim
{
Expand Down Expand Up @@ -81,7 +82,8 @@ FD FS::openFile(path_t filepath)
{
int fd = open(filepath.c_str(), O_RDONLY);
if (fd == -1) {
throw std::runtime_error("Error opening file: " + filepath);
const std::string errorStr = strerror(errno);
throw std::runtime_error("Error opening file: " + filepath + ": " + errorStr);
}
return FD(fd);
}
Expand Down

0 comments on commit a12d14a

Please sign in to comment.