Files
wc3re/exceptions.cc

48 lines
723 B
C++

#include <cstring>
#include <cerrno>
#include "exceptions.hh"
using namespace std::string_literals;
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_;
}
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_);
}