74 lines
1.1 KiB
C++
74 lines
1.1 KiB
C++
#include <cstring>
|
|
#include <cerrno>
|
|
|
|
#include "exceptions.hh"
|
|
|
|
Exception::Exception(std::string msg)
|
|
: msg_(std::move(msg))
|
|
{
|
|
}
|
|
|
|
Exception::~Exception()
|
|
{
|
|
}
|
|
|
|
std::string Exception::toString() const
|
|
{
|
|
return "Exception: " + msg_;
|
|
}
|
|
|
|
|
|
FormatException::FormatException(std::string msg)
|
|
: Exception(std::move(msg))
|
|
{
|
|
}
|
|
|
|
std::string FormatException::toString() const
|
|
{
|
|
return "FormatException: " + msg_;
|
|
}
|
|
|
|
|
|
PathException::PathException(std::string msg)
|
|
: Exception(std::move(msg))
|
|
{
|
|
}
|
|
|
|
std::string PathException::toString() const
|
|
{
|
|
return "PathException: " + msg_;
|
|
}
|
|
|
|
|
|
POSIXException::POSIXException(int err, std::string msg)
|
|
: Exception(std::move(msg)), err_(err)
|
|
{
|
|
}
|
|
|
|
int POSIXException::getErr() const
|
|
{
|
|
return err_;
|
|
}
|
|
|
|
std::string POSIXException::toString() const
|
|
{
|
|
return "POSIXException: " + msg_ + ": " + std::strerror(err_);
|
|
}
|
|
|
|
#ifdef WIN32
|
|
Win32Exception::Win32Exception(DWORD err, std::string msg)
|
|
: Exception(std::move(msg)), err_(err)
|
|
{
|
|
}
|
|
|
|
DWORD Win32Exception::getErr() const
|
|
{
|
|
return err_;
|
|
}
|
|
|
|
std::string Win32Exception::toString() const
|
|
{
|
|
return "Win32Exception: " + msg_ + ": " + std::to_string(err_);
|
|
}
|
|
#endif
|