0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-02-18 01:30:12 +01:00

ircd::fs: Make fs::error inherit from std::system_error.

This commit is contained in:
Jason Volk 2018-12-12 17:19:49 -08:00
parent 7792f00461
commit 04f3dc4d17
3 changed files with 24 additions and 12 deletions

View file

@ -95,7 +95,7 @@ struct ircd::exception
ssize_t generate(const string_view &fmt, const va_rtti &ap) noexcept;
public:
const char *what() const noexcept final override
const char *what() const noexcept override
{
return buf;
}

View file

@ -25,9 +25,10 @@ namespace ircd
}
struct ircd::fs::error
:ircd::error
:std::system_error
,ircd::error
{
std::error_code code;
const char *what() const noexcept override;
template<class... args>
error(const char *const &fmt = " ",
@ -60,14 +61,14 @@ ircd::fs::error::error(const boost::filesystem::filesystem_error &code)
inline
ircd::fs::error::error(const std::system_error &code)
:code{make_error_code(code)}
:std::system_error{code}
{
string(this->buf, code);
}
inline
ircd::fs::error::error(const std::error_code &code)
:code{code}
:std::system_error{code}
{
string(this->buf, code);
}
@ -98,23 +99,34 @@ template<class... args>
ircd::fs::error::error(const std::error_code &e,
const char *const &fmt,
args&&... a)
:ircd::error
{
fmt, std::forward<args>(a)...
}
,code
:std::system_error
{
make_error_code(e)
}
,ircd::error
{
fmt, std::forward<args>(a)...
}
{
}
template<class... args>
ircd::fs::error::error(const char *const &fmt,
args&&... a)
:ircd::error
:std::system_error
{
std::errc::invalid_argument
}
,ircd::error
{
fmt, std::forward<args>(a)...
}
{
}
inline const char *
ircd::fs::error::what()
const noexcept
{
return this->ircd::error::what();
}

View file

@ -167,7 +167,7 @@ catch(const fs::error &e)
{
throw http::error
{
e.code == std::errc::no_such_file_or_directory?
e.code() == std::errc::no_such_file_or_directory?
http::NOT_FOUND:
http::INTERNAL_SERVER_ERROR,