libdrmconf  0.10.4
A library to program DMR radios.
Classes | Public Member Functions | Protected Attributes | List of all members

Implements a stack of error messages to provide a pretty formatted error traceback. More...

#include <errorstack.hh>

Collaboration diagram for ErrorStack:
Collaboration graph
[legend]

Classes

class  Message
 Represents a single error message. More...
 
class  MessageStream
 A helper class to assemble error messages as streams. More...
 
class  Stack
 The actual error message stack. More...
 

Public Member Functions

 ErrorStack () noexcept
 Default constructor.
 
 ErrorStack (const ErrorStack &other)
 Copy constructor.
 
 ~ErrorStack ()
 Destructor.
 
ErrorStackoperator= (const ErrorStack &other)
 Copy assignment.
 
bool isEmpty () const
 Returns true, if the stack is empty.
 
unsigned count () const
 Returns the number of elements on the stack.
 
const Messagemessage (unsigned i) const
 Returns the i-th message from the stack.
 
void push (const Message &msg) const
 Pushes a message on the stack.
 
void take (const ErrorStack &other) const
 Takes all messages from the other stack.
 
QString format (const QString &indent=" ") const
 Returns a formatted string of error messages.
 

Protected Attributes

Stack_stack
 A reference to the actual message stack.
 

Detailed Description

Implements a stack of error messages to provide a pretty formatted error traceback.

This class is intended to be used like:

class MyClass: public ErrorStack
{
// [...]
bool someMethod(const ErrorStack &err=ErrorStack()) {
// [...]
if (someError) {
errMsg() << "Some error happened!";
return false;
}
// [...]
}
// [...]
}
Implements a stack of error messages to provide a pretty formatted error traceback.
Definition: errorstack.hh:41
ErrorStack() noexcept
Default constructor.
Definition: errorstack.cc:127

The error message can then be obtained using the public methods. E.g.,

// [...]
MyClass instance;
if (! instance.someMethod(err)) {
QString msg = err.formatErrorMessages();
// []
}

The documentation for this class was generated from the following files: