15 #include <zypp-core/base/Logger.h> 16 #include <zypp-core/base/LogTools.h> 17 #include <zypp-core/base/Gettext.h> 18 #include <zypp-core/base/StringV.h> 19 #include <zypp-core/base/Exception.h> 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 std::rethrow_exception(old_r);
133 }
catch (
const std::exception& e ) {
144 {
_history.push_front( std::move(msg_r) ); }
148 std::ostringstream ret;
150 ret <<
_(
"History:") << endl;
151 for (
const std::string & entry :
_history ) {
152 strv::split( entry,
"\n", [&ret]( std::string_view line_r,
unsigned idx,
bool last_r ) ->
void {
153 if ( not ( last_r && line_r.empty() ) )
154 ret << (idx==0?
" - ":
" ") << line_r << endl;
175 {
return strErrno( errno_r, std::string(msg_r) ); }
180 return msg_r +=
strErrno( errno_r );
184 const char *
const prefix_r )
186 INT << where_r <<
" " << prefix_r <<
" " << excpt_r.
asUserHistory() << endl;
190 const char *
const prefix_r )
192 INT << where_r <<
" " << prefix_r <<
" exception of type " << typename_r << endl;
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.
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::list< std::string > History
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.
virtual ~Exception()
Dtor.
Base class for Exception.
std::ostream & dumpError(std::ostream &str) const
Called by std::ostream & operator<<.
Keep FILE, FUNCTION and LINE.
std::string strerror(int errno_r)
Return string describing the error_r code.
Easy-to use interface to the ZYPP dependency resolver.
std::string asString() const
Location as string.