40 #ifndef PKGLIB_ERROR_H
41 #define PKGLIB_ERROR_H
43 #include <apt-pkg/macros.h>
76 bool FatalE(
const char *Function,
const char *Description,...) __like_printf(3) __cold;
85 bool Errno(const
char *Function,const
char *Description,...) __like_printf(3) __cold;
97 bool WarningE(const
char *Function,const
char *Description,...) __like_printf(3) __cold;
106 bool NoticeE(const
char *Function,const
char *Description,...) __like_printf(3) __cold;
115 bool DebugE(const
char *Function,const
char *Description,...) __like_printf(3) __cold;
124 const
char* Description,...) __like_printf(4) __cold;
142 const
char* Description, va_list &args,
143 int const errsv,
size_t &msgSize);
158 bool Fatal(const
char *Description,...) __like_printf(2) __cold;
166 bool Error(const
char *Description,...) __like_printf(2) __cold;
177 bool Warning(const
char *Description,...) __like_printf(2) __cold;
190 bool Notice(const
char *Description,...) __like_printf(2) __cold;
198 bool Debug(const
char *Description,...) __like_printf(2) __cold;
205 bool Insert(
MsgType const &type, const
char* Description,...) __like_printf(3) __cold;
221 va_list &args,
size_t &msgSize) __cold;
262 bool const &mergeStack =
true);
306 return Stacks.size();
316 Item(
char const *Text,
MsgType const &Type) :
317 Text(Text), Type(Type) {};
319 friend std::ostream& operator<< (std::ostream &out, Item i) {
322 case ERROR: out <<
"E";
break;
323 case WARNING: out <<
"W";
break;
324 case NOTICE: out <<
"N";
break;
325 case DEBUG: out <<
"D";
break;
327 return out <<
": " << i.Text;
331 std::list<Item> Messages;
335 std::list<Item>
const Messages;
336 bool const PendingFlag;
338 MsgStack(std::list<Item>
const &Messages,
bool const &Pending) :
339 Messages(Messages), PendingFlag(Pending) {};
342 std::list<MsgStack> Stacks;
349 #define _error _GetErrorObj()
void PushToStack()
put the current Messages into the stack
Definition: error.cc:245
bool Notice(const char *Description,...) __like_printf(2) __cold
add a notice message to the list
bool Error(const char *Description,...) __like_printf(2) __cold
add an Error message to the list
size_t StackCount() const
return the deep of the stack
Definition: error.h:305
An error does hinder the correct execution and should be corrected.
Definition: error.h:60
deprecation warnings, old fallback behavior, …
Definition: error.h:64
void DumpErrors()
dumps the messages of type WARNING or higher to std::cerr
Definition: error.h:283
void MergeWithStack()
merge current and stack together
Definition: error.cc:261
bool empty(MsgType const &trashhold=WARNING) const
is the list empty?
Definition: error.cc:229
bool InsertErrno(MsgType const &type, const char *Function, const char *Description,...) __like_printf(4) __cold
adds an errno message with the given type
Definition: error.cc:85
MsgType
a message can have one of following severity
Definition: error.h:55
bool NoticeE(const char *Function, const char *Description,...) __like_printf(3) __cold
add a notice message with errno to the list
bool Fatal(const char *Description,...) __like_printf(2) __cold
add an fatal error message to the list
void DumpErrors(MsgType const &threshold)
dumps the list of messages to std::cerr
Definition: error.h:271
Message will be printed instantly as it is likely that this error will lead to a complete crash...
Definition: error.h:58
bool WarningE(const char *Function, const char *Description,...) __like_printf(3) __cold
add a warning message with errno to the list
indicates problem that can lead to errors later on
Definition: error.h:62
bool DebugE(const char *Function, const char *Description,...) __like_printf(3) __cold
add a debug message with errno to the list
for developers only in areas it is hard to print something directly
Definition: error.h:66
bool Debug(const char *Description,...) __like_printf(2) __cold
add a debug message to the list
bool Errno(const char *Function, const char *Description,...) __like_printf(3) __cold
add an Error message with errno to the list
bool Warning(const char *Description,...) __like_printf(2) __cold
add a warning message to the list
bool FatalE(const char *Function, const char *Description,...) __like_printf(3) __cold
add a fatal error message with errno to the list
bool PopMessage(std::string &Text)
returns and removes the first (or last) message in the list
Definition: error.cc:185
void Discard()
clears the list of messages
Definition: error.cc:223
bool Insert(MsgType const &type, const char *Description,...) __like_printf(3) __cold
adds an error message with the given type
Definition: error.cc:143
void RevertToStack()
throw away all current messages
Definition: error.cc:252
bool PendingError() const
is an error in the list?
Definition: error.h:227