4 #include "sopt/config.h"
14 Exception(std::string
const &name, std::string
const &filename,
size_t lineno)
15 : std::exception(), message(
header(name, filename, lineno)) {}
19 Exception(std::string
const &filename,
size_t lineno)
20 :
Exception(
"sopt::Exception", filename, lineno) {}
23 const char *
what() const noexcept
override {
return message.c_str(); }
26 static std::string
header(std::string
const &name, std::string
const &filename,
size_t lineno) {
28 header << name <<
" at " << filename <<
":" << lineno;
33 template <
typename OBJECT>
35 std::ostringstream msg;
36 msg << message << object;
46 #define SOPT_THROW(MSG) throw(sopt::Exception(__FILE__, __LINE__) << "\n" << MSG)
static std::string header(std::string const &name, std::string const &filename, size_t lineno)
Header of the message.
Exception(std::string const &filename, size_t lineno)
Creates exception.
const char * what() const noexcept override
Creates message.
Exception & operator<<(OBJECT const &object)
Adds to message.