libdrmconf 0.15.0
A library to program DMR radios.
Loading...
Searching...
No Matches

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

#include <errorstack.hh>

Collaboration diagram for ErrorStack:

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.
ErrorStack & operator= (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 Message & message (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;
}
// [...]
}
// [...]
}
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:
  • /builddir/build/BUILD/qdmr-0.15.0-build/qdmr-0.15.0/lib/errorstack.hh
  • /builddir/build/BUILD/qdmr-0.15.0-build/qdmr-0.15.0/lib/errorstack.cc