Qx v0.7
Qt Extensions Library
Loading...
Searching...
No Matches
Qx::SqlError Class Referencefinal

The SqlError class is used to report errors related to database configuration and SQL queries.

#include <qx/sql/qx-sqlerror.h>

Inheritance diagram for Qx::SqlError:
[legend]

Public Types

enum  Form {
  NoError ,
  MissingDb ,
  EngineError ,
  TypeMismatch ,
  MissingField ,
  InvalidResult
}
 

Public Member Functions

 SqlError ()
 
 SqlError (const QSqlError &engineError)
 
 SqlError (Form f, const QString &c={})
 
QString cause () const
 
QString databaseInfo () const
 
Form form () const
 
bool isValid () const
 
QString query () const
 
SqlErrorwithDatabase (const SqlDatabase &db)
 
SqlErrorwithQuery (const QString &q)
 
SqlErrorwithQuery (const SqlQuery &q)
 
- Public Member Functions inherited from Qx::AbstractError<"Qx::SqlError", 7 >
 operator bool () const
 
bool operator!= (const AbstractError &other) const=default
 
bool operator== (const AbstractError &other) const=default
 

Friends

template<typename T>
struct QxSqlPrivate::FieldChecker
 

Additional Inherited Members

- Static Public Attributes inherited from Qx::AbstractError<"Qx::SqlError", 7 >
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
 

Member Enumeration Documentation

◆ Form

This enum represents the form of SQL error.

Enumerator
NoError 

No error occurred.

EngineError 

An error occurred in the underlying database engine/driver.

TypeMismatch 

A SQL value was not of the expected type.

MissingField 

An expected SQL field was missing.

Constructor & Destructor Documentation

◆ SqlError() [1/3]

Qx::SqlError::SqlError ( )

Creates an invalid SqlError.

◆ SqlError() [2/3]

Qx::SqlError::SqlError ( Form f,
const QString & c = {} )

Creates a SQL error with the form f and cause c.

◆ SqlError() [3/3]

Qx::SqlError::SqlError ( const QSqlError & engineError)

Creates a SQL error from engineError.

Member Function Documentation

◆ cause()

QString Qx::SqlError::cause ( ) const

The primary cause of the error.

◆ databaseInfo()

QString Qx::SqlError::databaseInfo ( ) const

Textual information above the database that the error originated from.

◆ form()

SqlError::Form Qx::SqlError::form ( ) const

The form of error that occurred.

◆ isValid()

bool Qx::SqlError::isValid ( ) const

Returns true if an error occurred; otherwise, returns false.

◆ query()

QString Qx::SqlError::query ( ) const

The query used when the error occurred, if any.

◆ withDatabase()

SqlError & Qx::SqlError::withDatabase ( const SqlDatabase & db)

Sets the database associated with the error and returns a reference to the error.

◆ withQuery() [1/2]

SqlError & Qx::SqlError::withQuery ( const QString & q)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ withQuery() [2/2]

SqlError & Qx::SqlError::withQuery ( const SqlQuery & q)

Sets the query associated with the error and returns a reference to the error.


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