firfuorida  0.0.1
Qt based database migration library
Public Types | Public Member Functions | Related Functions | List of all members
Firfuorida::Error Class Reference

Provides error information. More...

#include <Firfuorida/Error>

Public Types

enum  ErrorType : uint8_t {
  NoError = 0, SqlError = 1, FileSystemError = 2, InternalError = 3,
  UnknownError = 255
}
 This enum type describes the context in which the error occurred. More...
 

Public Member Functions

 Error ()
 Constructs a new Error object of type NoError. More...
 
 Error (ErrorType type, const QString &text)
 Constructs a new Error object with given type and text. More...
 
 Error (const QSqlError &sqlError, const QString &text)
 Constucts a new Error object with given sqlError and text. More...
 
 Error (const Error &other)
 Constructs a copy of other. More...
 
 Error (Error &&other) noexcept
 Move-constructs an Error instance, making it point at the same object that other was pointing to. More...
 
 ~Error ()
 Deconstructs the Error object. More...
 
bool operator!= (const Error &other) const noexcept
 Returns true if this and other have not the same content; otherwise returns false. More...
 
Erroroperator= (const Error &other)
 Assigns other to this Error and returns a reference to this instance. More...
 
Erroroperator= (Error &&other) noexcept
 Move-assigns other to this Error instance. More...
 
bool operator== (const Error &other) const noexcept
 Returns true if this and other have the same content; otherwise returns false. More...
 
QSqlError sqlError () const
 Returns the QSqlError object if this error is of type SqlError. More...
 
void swap (Error &other) noexcept
 Swaps this Error instance with other. More...
 
QString text () const
 Returns the error text. More...
 
ErrorType type () const
 Returns the type of this error. More...
 

Related Functions

(Note that these are not member functions.)

FIRFUORIDA_EXPORT QDebug operator<< (QDebug dbg, const Firfuorida::Error &error)
 Writes the text() of error to the dbg stream and returns the stream. More...
 

Detailed Description

Provides error information.

The Error class provides information about occured errors. Use type() to check if an error has occure. text() will return the error text. If the error is an SqlError, there will also be a valid QSqlError returned by sqlError().

Member Enumeration Documentation

◆ ErrorType

This enum type describes the context in which the error occurred.

Enumerator
NoError 

No error occured.

SqlError 

A SQL error occured, sqlError() will return a valid QSqlError object.

FileSystemError 

A filesystem error occured.

InternalError 

An internal error occured.

UnknownError 

An unknown error occured.

Constructor & Destructor Documentation

◆ Error() [1/5]

Error::Error ( )

Constructs a new Error object of type NoError.

◆ Error() [2/5]

Error::Error ( ErrorType  type,
const QString text 
)

Constructs a new Error object with given type and text.

◆ Error() [3/5]

Error::Error ( const QSqlError sqlError,
const QString text 
)

Constucts a new Error object with given sqlError and text.

The type() will automatically set to SqlError.

◆ Error() [4/5]

Error::Error ( const Error other)
default

Constructs a copy of other.

◆ Error() [5/5]

Error::Error ( Error &&  other)
defaultnoexcept

Move-constructs an Error instance, making it point at the same object that other was pointing to.

◆ ~Error()

Error::~Error ( )
default

Deconstructs the Error object.

Member Function Documentation

◆ operator!=()

bool Firfuorida::Error::operator!= ( const Error other) const
inlinenoexcept

Returns true if this and other have not the same content; otherwise returns false.

◆ operator=() [1/2]

Error & Error::operator= ( const Error other)
default

Assigns other to this Error and returns a reference to this instance.

◆ operator=() [2/2]

Error & Error::operator= ( Error &&  other)
defaultnoexcept

Move-assigns other to this Error instance.

◆ operator==()

bool Error::operator== ( const Error other) const
noexcept

Returns true if this and other have the same content; otherwise returns false.

◆ sqlError()

QSqlError Error::sqlError ( ) const

Returns the QSqlError object if this error is of type SqlError.

◆ swap()

void Error::swap ( Error other)
noexcept

Swaps this Error instance with other.

◆ text()

QString Error::text ( ) const

Returns the error text.

If error is of type() SqlError, the text will also contain the text returned by QSqlError::text();

◆ type()

Error::ErrorType Error::type ( ) const

Returns the type of this error.

Friends And Related Function Documentation

◆ operator<<()

FIRFUORIDA_EXPORT QDebug operator<< ( QDebug  dbg,
const Firfuorida::Error error 
)
related

Writes the text() of error to the dbg stream and returns the stream.