26 namespace exception_detail
53 : _msg( std::move(msg_r) )
61 : _msg( std::move(msg_r) )
66 {
remember( std::move(history_r) ); }
69 : _msg( std::move(msg_r) )
70 {
remember( std::move(history_r) ); }
77 std::ostringstream str;
84 std::ostringstream str;
88 return _(str.str().c_str());
107 if ( &old_r !=
this )
117 if ( &old_r !=
this )
119 History & newh( old_r._history );
120 newh.push_front( old_r.asUserString() );
129 {
_history.push_front( std::move(msg_r) ); }
134 std::string history(
_(
"History:") );
135 std::ostringstream ret;
137 "", history+
"\n - ",
"\n - ",
"\n",
"" );
142 {
return str <<
_msg; }
155 {
return strErrno( errno_r, std::string(msg_r) ); }
160 return msg_r +=
strErrno( errno_r );
164 const char *
const prefix_r )
166 INT << where_r <<
" " << prefix_r <<
" " << excpt_r.
asUserHistory() << endl;
std::string historyAsString() const
The history as string.
std::ostream & operator<<(std::ostream &str, const CodeLocation &obj)
bool historyEmpty() const
Whether the history list is empty.
static std::string strErrno(int errno_r)
Make a string from errno_r.
void addHistory(const std::string &msg_r)
Add some message text to the history.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
HistoryIterator historyBegin() const
Iterator pointing to the most recent message.
void remember(const Exception &old_r)
Store an other Exception as history.
static void log(const Exception &excpt_r, const CodeLocation &where_r, const char *const prefix_r)
Drop a logline on throw, catch or rethrow.
std::ostream & dumpRange(std::ostream &str, TIterator begin, TIterator end, const std::string &intro="{", const std::string &pfx="\n ", const std::string &sep="\n ", const std::string &sfx="\n", const std::string &extro="}")
Print range defined by iterators (multiline style).
std::ostream & operator<<(std::ostream &str, const Exception &obj)
std::list< std::string > History
std::ostream & dumpError(std::ostream &str) const
Called by std::ostream & operator<<.
std::string asString() const
Error message provided by dumpOn as string.
virtual ~Exception()
Dtor.
std::string asString() const
Location as string.
HistoryIterator historyEnd() const
Iterator pointing behind the last message.
Base class for Exception.
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
Keep FILE, FUNCTION and LINE.
std::string strerror(int errno_r)
Return string describing the error_r code.
std::string asUserString() const
Translated error message as string suitable for the user.