Base class for objet reporting errors. More...
Public Member Functions | |
virtual | ~QtlErrorBase () |
Virtual destructor. More... | |
bool | autoReport () const |
Check if errors are automatically reported and displayed to the user. More... | |
QString | errorMessage () const |
Get the last error message. More... | |
QtlLogger * | log () const |
Get the error logger. More... | |
void | setAutoReport (bool autoReport) |
Set if errors are automatically reported and displayed to the user. More... | |
bool | success () const |
Check if the last operation was successful. More... | |
bool | valid () const |
Check if the object is valid for use. More... | |
Protected Types | |
enum | ErrorType { QTL_ERROR, QTL_INVALIDATE, QTL_FATAL } |
Type of error to report. More... | |
Protected Member Functions | |
QtlErrorBase (QObject *parent, QtlLogger *log, bool autoReport) | |
Protected constructor for subclasses. More... | |
QtlErrorBase (const QtlErrorBase &other) | |
Copy constructor. More... | |
void | invalidate () |
Invalidate this object without reporting a message. More... | |
const QtlErrorBase & | operator= (const QtlErrorBase &other) |
Assignment operator. More... | |
void | reportError (const QString &message=QString(), bool fatal=false) const |
Report an error message. More... | |
void | setError (const QString &message, ErrorType type=QTL_ERROR) const |
Set an error message. More... | |
void | setSuccess () const |
Report success of the last operation. More... | |
Private Attributes | |
bool | _autoReport |
Automatically report errors. More... | |
QString | _errorMessage |
Error message. More... | |
QtlLogger * | _log |
Where to log errors, never null. More... | |
bool | _success |
True if last operation was successful. More... | |
bool | _valid |
True if the object is valid for use. More... | |
Static Private Attributes | |
static QtlNullLogger | _nullLog |
A void error logger. More... | |
Base class for objet reporting errors.
|
protected |
|
inlinevirtual |
Virtual destructor.
|
protected |
Protected constructor for subclasses.
The object is initially invalid, the subclass constructor shall validate it if necessary.
[in] | parent | Parent object. |
[in] | log | Where to log errors. |
[in] | autoReport | Automatically report errors. |
|
protected |
Copy constructor.
The new object has no parent, it does not copy other's parent.
[in] | other | Other instance to copy. |
|
inline |
Get the error logger.
|
inline |
Check if the object is valid for use.
|
inline |
Check if the last operation was successful.
|
inline |
Get the last error message.
If valid() is false, return the reason why the object is invalid.
|
inline |
Check if errors are automatically reported and displayed to the user.
|
inline |
Set if errors are automatically reported and displayed to the user.
[in] | autoReport | True if errors are automatically reported, false otherwise. |
|
protected |
Assignment operator.
The object's parent is unchanged.
[in] | other | Other instance to copy. |
|
protected |
Report success of the last operation.
|
protected |
Invalidate this object without reporting a message.
Set an error message.
[in] | message | The error message. |
[in] | type | Error type. |
|
protected |
Report an error message.
[in] | message | The error message. If omitted, use the current error message of this instance. If still empty, do not report anything. |
[in] | fatal | If true, the application is aborted and this function never returns. |
|
staticprivate |
A void error logger.
|
private |
Where to log errors, never null.
|
mutableprivate |
True if the object is valid for use.
|
mutableprivate |
True if last operation was successful.
|
mutableprivate |
Automatically report errors.
|
mutableprivate |
Error message.