io: record path in path_error

This commit is contained in:
Danny Robson 2016-02-12 13:36:03 +11:00
parent 0af631e975
commit 18c3a1eaaf
2 changed files with 22 additions and 4 deletions

15
io.cpp
View File

@ -201,3 +201,18 @@ scoped_cwd::~scoped_cwd ()
if (!chdir (m_original.c_str ()))
errno_error::throw_code ();
}
///////////////////////////////////////////////////////////////////////////////
path_error::path_error (const boost::filesystem::path &_path):
runtime_error (format::render ("Unknown path: %!", m_path)),
m_path (_path)
{ ; }
//-----------------------------------------------------------------------------
const char*
path_error::path (void) const noexcept
{
return m_path.c_str ();
}

11
io.hpp
View File

@ -134,10 +134,13 @@ namespace util {
//-------------------------------------------------------------------------
class path_error : public std::runtime_error {
public:
path_error (const boost::filesystem::path &path):
runtime_error ("Invalid path " + path.string ())
{ ; }
public:
path_error (const boost::filesystem::path &path);
const char* path (void) const noexcept;
private:
const boost::filesystem::path m_path;
};
}