Qx v0.5.8
Qt Extensions Library
|
The JsonError class is used to report errors related to JSON manipulation.
#include <qx/core/qx-json.h>
Public Types | |
enum | Form { NoError = 0 , MissingKey , TypeMismatch , EmptyDoc , MissingFile , InaccessibleFile , FileReadError , FileWriteError } |
Public Member Functions | |
JsonError () | |
JsonError (const QString &a, Form f) | |
QString | action () const |
QList< QxJson::ContextNode > | context () const |
Form | form () const |
bool | isValid () const |
JsonError & | withContext (const QxJson::ContextNode &node) |
Public Member Functions inherited from Qx::AbstractError<"Qx::JsonError", 5 > | |
operator bool () const | |
bool | operator!= (const AbstractError &other) const=default |
bool | operator== (const AbstractError &other) const=default |
Additional Inherited Members | |
Static Public Attributes inherited from Qx::AbstractError<"Qx::JsonError", 5 > | |
static constexpr quint16 | TYPE_CODE |
static constexpr QLatin1StringView | TYPE_NAME |
Protected Member Functions inherited from Qx::IError | |
IError ()=default | |
virtual QString | deriveCaption () const |
virtual Severity | deriveSeverity () const |
bool | operator!= (const IError &other) const =default |
bool | operator== (const IError &other) const =default |
enum Qx::JsonError::Form |
This enum represents form of JSON error.
Qx::JsonError::JsonError | ( | ) |
Creates an invalid JsonError.
Creates a JSON error with the action and error form f.
QString Qx::JsonError::action | ( | ) | const |
A message noting the attempted action that failed.
QList< QxJson::ContextNode > Qx::JsonError::context | ( | ) | const |
Provides the full context in which the error occurred.
JsonError::Form Qx::JsonError::form | ( | ) | const |
The form of error that occurred.
bool Qx::JsonError::isValid | ( | ) | const |
Returns true
if an error occurred; otherwise, returns false
.
JsonError & Qx::JsonError::withContext | ( | const QxJson::ContextNode & | node | ) |
Prepends the context node node to the error's context and returns a reference to the updated error object. This function is a no-op if the error is not valid.
Generally this function is of no use in user code, but can be utilized when providing complex custom parsing for user types via QX_JSON_MEMBER_OVERRIDE or Converter specializations.
Typically, this function is used in a chain of return calls in order to pass the context of where an error occurred up the call stack. For example, one might return information about a JSON array related error like so: