9 #ifndef CPPCOMMON_ERRORS_EXCEPTIONS_H
10 #define CPPCOMMON_ERRORS_EXCEPTIONS_H
23 #define throwex throw __LOCATION__ +
54 const char*
what() const noexcept override;
57 virtual std::
string string() const;
60 friend std::ostream& operator<<(std::ostream& os, const
Exception& ex)
61 { os << ex.string();
return os; }
66 { instance._location =
location;
return std::forward<T>(instance); }
144 std::string
string()
const override;
const char * what() const noexcept override
Get string identifying exception.
SourceLocation _location
Exception location.
const std::string & message() const noexcept
Get exception message.
Exception & operator=(Exception &&)=default
std::string _message
Exception message.
Exception & operator=(const Exception &)=default
std::string _cache
Cached exception string.
friend T && operator+(const SourceLocation &location, T &&instance)
Link exception with source location.
Exception(Exception &&)=default
Exception(const Exception &)=default
virtual ~Exception()=default
const SourceLocation & location() const noexcept
Get exception location.
Exception(const std::string &message="")
Default class constructor.
int _system_error
System error code.
SystemException(const std::string &message, int error)
Create system exception based on the given exception message and system error code.
int system_error() const noexcept
Get system error code.
std::string _system_message
System error message.
std::string string() const override
Get string from the current system exception.
SystemException(int error)
Create system exception based on the given system error code.
SystemException(const std::string &message)
Create system exception based on the given exception message.
const std::string & system_message() const noexcept
Get system error message.
SystemException()
Create system exception based on the last system error code.
Exceptions inline implementation.
C++ Common project definitions.
Source location definition.