26 namespace exception_detail
47 std::rethrow_exception (excpt_r);
51 }
catch (
const std::exception & e ) {
72 : _msg(
std::move(msg_r) )
80 : _msg(
std::move(msg_r) )
85 {
remember( std::move(history_r) ); }
88 : _msg(
std::move(msg_r) )
89 {
remember( std::move(history_r) ); }
96 std::ostringstream
str;
103 std::ostringstream
str;
107 return _(
str.str().c_str());
126 if ( &old_r !=
this )
136 if ( &old_r !=
this )
138 History & newh( old_r._history );
139 newh.push_front( old_r.asUserString() );
148 std::rethrow_exception(std::move(old_r));
152 }
catch (
const std::exception& e ) {
163 {
_history.push_front( std::move(msg_r) ); }
167 std::ostringstream ret;
169 ret <<
_(
"History:") << endl;
170 for (
const std::string & entry :
_history ) {
171 strv::split( entry,
"\n", [&ret]( std::string_view line_r,
unsigned idx,
bool last_r ) ->
void {
172 if ( not ( last_r && line_r.empty() ) )
173 ret << (idx==0?
" - ":
" ") << line_r << endl;
196 return msg_r +=
strErrno( errno_r );
200 const char *
const prefix_r )
202 INT << where_r <<
" " << prefix_r <<
" " << excpt_r.
asUserHistory() << endl;
206 const char *
const prefix_r )
208 INT << where_r <<
" " << prefix_r <<
" exception of type " << typename_r << endl;
void do_ZYPP_RETHROW(const std::exception_ptr &excpt_r, const CodeLocation &where_r)
std::ostream & operator<<(std::ostream &str, const CodeLocation &obj)
virtual std::ostream & dumpOn(std::ostream &str) const
Overload this to print a proper error message.
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.
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
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::string strerror(int errno_r)
Return string describing the error_r code.
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \, const Trim trim_r=NO_TRIM)
Split line_r into words.
std::string asString() const
Error message provided by dumpOn as string.
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
std::string asUserString() const
Translated error message as string suitable for the user.
bool historyEmpty() const
Whether the history list is empty.
std::string historyAsString() const
The history as string.
Base class for Exception.
std::ostream & dumpError(std::ostream &str) const
Called by std::ostream & operator<<.
~Exception() override
Dtor.
Keep FILE, FUNCTION and LINE.
std::list< std::string > History
Easy-to use interface to the ZYPP dependency resolver.
std::string asString() const
Location as string.