libzypp 17.35.1
|
Base class for Exception. More...
#include <zypp-core/base/Exception.h>
Public Types | |
using | CodeLocation = exception_detail::CodeLocation |
using | History = std::list<std::string> |
using | HistoryIterator = History::const_iterator |
using | HistorySize = History::size_type |
Public Member Functions | |
Exception () | |
Default ctor. | |
Exception (const std::string &msg_r) | |
Ctor taking a message. | |
Exception (std::string &&msg_r) | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Exception (const std::string &msg_r, const Exception &history_r) | |
Ctor taking a message and an exception to remember as history. | |
Exception (std::string &&msg_r, const Exception &history_r) | |
Exception (const std::string &msg_r, Exception &&history_r) | |
Exception (std::string &&msg_r, Exception &&history_r) | |
~Exception () override throw () | |
Dtor. | |
const CodeLocation & | where () const |
Return CodeLocation. | |
void | relocate (const CodeLocation &where_r) const |
Exchange location on rethrow. | |
const std::string & | msg () const |
Return the message string provided to the ctor. | |
std::string | asString () const |
Error message provided by dumpOn as string. | |
std::string | asUserString () const |
Translated error message as string suitable for the user. | |
Friends | |
std::ostream & | operator<< (std::ostream &str, const Exception &obj) |
Related Symbols | |
(Note that these are not member symbols.) | |
std::ostream & | operator<< (std::ostream &str, const Exception &obj) ZYPP_API |
Stream output. | |
History list of message strings. | |
Maintain a simple list of individual error messages, that lead to this Exception. The Exceptions message itself is not included in the history. The History list stores the most recent message fist. | |
CodeLocation | _where |
std::string | _msg |
History | _history |
void | remember (const Exception &old_r) |
Store an other Exception as history. | |
void | remember (Exception &&old_r) |
void | remember (std::exception_ptr old_r) |
void | remember (const std::string &msg_r) |
Remembering a plain string is most probably not wanted - we addHistory. | |
void | remember (std::string &&msg_r) |
void | addHistory (const std::string &msg_r) |
Add some message text to the history. | |
void | addHistory (std::string &&msg_r) |
template<class TContainer > | |
void | addToHistory (const TContainer &msgc_r) |
addHistory from string container types (oldest first) | |
template<class TContainer > | |
void | moveToHistory (TContainer &&msgc_r) |
addHistory from string container types (oldest first) moving | |
HistoryIterator | historyBegin () const |
Iterator pointing to the most recent message. | |
HistoryIterator | historyEnd () const |
Iterator pointing behind the last message. | |
bool | historyEmpty () const |
Whether the history list is empty. | |
HistorySize | historySize () const |
The size of the history list. | |
std::string | historyAsString () const |
The history as string. | |
std::string | asUserHistory () const |
A single (multiline) string composed of asUserString and historyAsString. | |
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. | |
static std::string | strErrno (int errno_r, std::string msg_r) |
Make a string from errno_r and msg_r. | |
static void | log (const Exception &excpt_r, const CodeLocation &where_r, const char *const prefix_r) |
Drop a logline on throw, catch or rethrow. | |
static void | log (const char *typename_r, const CodeLocation &where_r, const char *const prefix_r) |
\overrload for not-Exception types thrown via ZYPP_THROW | |
const char * | what () const override throw () |
Return message string. | |
std::ostream & | dumpError (std::ostream &str) const |
Called by std::ostream & operator<< . | |
Base class for Exception.
Exception offers to store a message string passed to the ctor. Derived classes may provide additional information. Overload dumpOn to provide a proper error text.
The use of these macros is not mandatory. but ZYPP_THROW
and ZYPP_RETHROW
will adjust the code location information stored in the Exception. All three macros will drop a line in the logfile.
The above produces the following log lines:
Class Exception now offers a history list of message strings. These messages should describe what lead to the exception.
The Exceptions message itself is NOT included in the history.
Rethrow, remembering an old exception:
Print an Exception, followed by its history, if available:
Definition at line 146 of file Exception.h.
Definition at line 151 of file Exception.h.
using zypp::Exception::History = std::list<std::string> |
Definition at line 152 of file Exception.h.
using zypp::Exception::HistoryIterator = History::const_iterator |
Definition at line 153 of file Exception.h.
using zypp::Exception::HistorySize = History::size_type |
Definition at line 154 of file Exception.h.
zypp::Exception::Exception | ( | ) |
Default ctor.
Use ZYPP_THROW macros to throw exceptions.
Definition at line 81 of file Exception.cc.
zypp::Exception::Exception | ( | const std::string & | msg_r | ) |
Ctor taking a message.
Use ZYPP_THROW macros to throw exceptions.
Definition at line 84 of file Exception.cc.
zypp::Exception::Exception | ( | std::string && | msg_r | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 88 of file Exception.cc.
zypp::Exception::Exception | ( | const std::string & | msg_r, |
const Exception & | history_r ) |
Ctor taking a message and an exception to remember as history.
Definition at line 92 of file Exception.cc.
zypp::Exception::Exception | ( | std::string && | msg_r, |
const Exception & | history_r ) |
Definition at line 96 of file Exception.cc.
zypp::Exception::Exception | ( | const std::string & | msg_r, |
Exception && | history_r ) |
Definition at line 100 of file Exception.cc.
zypp::Exception::Exception | ( | std::string && | msg_r, |
Exception && | history_r ) |
Definition at line 104 of file Exception.cc.
|
override |
Dtor.
Definition at line 108 of file Exception.cc.
|
inline |
Return CodeLocation.
Definition at line 184 of file Exception.h.
|
inline |
Exchange location on rethrow.
Definition at line 188 of file Exception.h.
|
inline |
Return the message string provided to the ctor.
Definition at line 196 of file Exception.h.
std::string zypp::Exception::asString | ( | ) | const |
Error message provided by dumpOn as string.
Definition at line 111 of file Exception.cc.
std::string zypp::Exception::asUserString | ( | ) | const |
Translated error message as string suitable for the user.
Definition at line 118 of file Exception.cc.
Store an other Exception as history.
Definition at line 141 of file Exception.cc.
Definition at line 151 of file Exception.cc.
void zypp::Exception::remember | ( | std::exception_ptr | old_r | ) |
Definition at line 161 of file Exception.cc.
|
inline |
Remembering a plain string is most probably not wanted - we addHistory.
It would discards the old history and replace it with this string. If that's actually your intent, explicitly wrap it into an Exception.
Definition at line 228 of file Exception.h.
|
inline |
Definition at line 231 of file Exception.h.
void zypp::Exception::addHistory | ( | const std::string & | msg_r | ) |
Add some message text to the history.
Definition at line 176 of file Exception.cc.
void zypp::Exception::addHistory | ( | std::string && | msg_r | ) |
Definition at line 179 of file Exception.cc.
addHistory from string container types (oldest first)
Definition at line 241 of file Exception.h.
addHistory from string container types (oldest first) moving
Definition at line 248 of file Exception.h.
|
inline |
Iterator pointing to the most recent message.
Definition at line 255 of file Exception.h.
|
inline |
Iterator pointing behind the last message.
Definition at line 259 of file Exception.h.
|
inline |
Whether the history list is empty.
Definition at line 263 of file Exception.h.
|
inline |
The size of the history list.
Definition at line 267 of file Exception.h.
std::string zypp::Exception::historyAsString | ( | ) | const |
The history as string.
Empty if historyEmpty. Otherwise:
Definition at line 182 of file Exception.cc.
std::string zypp::Exception::asUserHistory | ( | ) | const |
A single (multiline) string composed of asUserString and historyAsString.
Definition at line 127 of file Exception.cc.
|
protectedvirtual |
Overload this to print a proper error message.
Reimplemented in zypp::UserRequestException, zypp::parser::ParseException, zypp::media::MediaMountException, zypp::media::MediaUnmountException, zypp::media::MediaJammedException, zypp::media::MediaBadFilenameException, zypp::media::MediaNotOpenException, zypp::media::MediaFileNotFoundException, zypp::media::MediaWriteException, zypp::media::MediaNotAttachedException, zypp::media::MediaBadAttachPointException, zypp::media::MediaCurlInitException, zypp::media::MediaSystemException, zypp::media::MediaNotAFileException, zypp::media::MediaNotADirException, zypp::media::MediaBadUrlException, zypp::media::MediaBadUrlEmptyHostException, zypp::media::MediaBadUrlEmptyFilesystemException, zypp::media::MediaBadUrlEmptyDestinationException, zypp::media::MediaUnsupportedUrlSchemeException, zypp::media::MediaNotSupportedException, zypp::media::MediaCurlException, zypp::media::MediaCurlSetOptException, zypp::media::MediaNotDesiredException, zypp::media::MediaIsSharedException, zypp::media::MediaNotEjectedException, zypp::media::MediaUnauthorizedException, zypp::media::MediaForbiddenException, zypp::media::MediaTimeoutException, zypp::media::MediaFileSizeExceededException, zypp::media::MediaTemporaryProblemException, zypp::media::MediaBadCAException, zypp::repo::RepoException, zypp::repo::ServiceException, zypp::target::rpm::RpmInvalidRootException, zypp::target::rpm::RpmAccessBlockedException, zypp::target::rpm::RpmSubprocessException, zypp::target::rpm::RpmInitException, zypp::target::rpm::RpmDbOpenException, zypp::target::rpm::RpmDbAlreadyOpenException, zypp::target::rpm::RpmDbNotOpenException, zypp::target::rpm::RpmDbConvertException, zypp::target::rpm::RpmNullDatabaseException, zypp::target::rpm::RpmTransactionFailedException, and zypp::target::TargetAbortedException.
Definition at line 197 of file Exception.cc.
|
static |
Make a string from errno_r.
Definition at line 207 of file Exception.cc.
|
static |
Make a string from errno_r and msg_r.
Definition at line 210 of file Exception.cc.
|
static |
Drop a logline on throw, catch or rethrow.
Used by ZYPP_THROW macros macros.
Definition at line 216 of file Exception.cc.
|
static |
\overrload for not-Exception types thrown via ZYPP_THROW
Definition at line 222 of file Exception.cc.
|
inlineoverrideprivate |
Return message string.
Definition at line 312 of file Exception.h.
|
private |
Called by std::ostream & operator<<
.
Prints CodeLocation and the error message provided by dumpOn.
Definition at line 200 of file Exception.cc.
|
friend |
Definition at line 203 of file Exception.cc.
|
related |
Stream output.
Definition at line 203 of file Exception.cc.
|
mutableprivate |
Definition at line 307 of file Exception.h.
|
private |
Definition at line 308 of file Exception.h.
|
private |
Definition at line 309 of file Exception.h.