Qx v0.5.8
Qt Extensions Library
Loading...
Searching...
No Matches
Qx::SystemError Class Referencefinal

The SystemError class encapsulates system generated errors as an Qx::Error interface compatible object. More...

#include <qx/core/qx-systemerror.h>

Collaboration diagram for Qx::SystemError:
[legend]

Public Types

enum  OriginalFormat {
  Invalid ,
  Hresult ,
  NtStatus ,
  Errno
}
 

Public Member Functions

 SystemError ()
 
QString actionError () const
 
QString cause () const
 
bool isValid () const
 
OriginalFormat originalFormat () const
 
quint32 value () const
 
- Public Member Functions inherited from Qx::AbstractError<"Qx::SystemError", 2 >
 operator bool () const
 
bool operator!= (const AbstractError &other) const=default
 
bool operator== (const AbstractError &other) const=default
 

Static Public Member Functions

static SystemError fromErrno (int err, QString aError="System Error")
 
static SystemError fromHresult (HRESULT res, QString aError=u"System Error"_s)
 
static SystemError fromNtStatus (NTSTATUS res, QString aError=u"System Error"_s)
 

Additional Inherited Members

- Static Public Attributes inherited from Qx::AbstractError<"Qx::SystemError", 2 >
static constexpr quint16 TYPE_CODE
 
static constexpr QLatin1StringView TYPE_NAME
 
- Protected Member Functions inherited from Qx::IError
 IError ()=default
 
virtual QString deriveCaption () const
 
virtual QString deriveDetails () const
 
bool operator!= (const IError &other) const =default
 
bool operator== (const IError &other) const =default
 

Detailed Description

Instances of this class correspond to a specific type of system error that is operating system dependent. Factory methods for each are available for each type on its corresponding system.

Member Enumeration Documentation

◆ OriginalFormat

This enum represents the original error format of a given SystemError.

Enumerator
Invalid 

Used only for an invalid SystemError.

Hresult 

Windows HRESULT.

NtStatus 

Windows NTSTATUS.

Errno 

POSIX errno.

Constructor & Destructor Documentation

◆ SystemError()

Qx::SystemError::SystemError ( )

Constructs an invalid system error.

See also
isValid().

Member Function Documentation

◆ actionError()

QString Qx::SystemError::actionError ( ) const

Returns the system activity that preceded the error.

See also
cause().

◆ cause()

QString Qx::SystemError::cause ( ) const

Returns the cause of the error. Usually, this a system dependent string representation of the error's code.

See also
code().

◆ fromErrno()

SystemError Qx::SystemError::fromErrno ( int err,
QString aError = "System Error" )
static

Returns a system error based on the errno value err and with the action error aError.

The error's value is set directly to the value of err, while it's cause() will contain a string representation of the value.

Note
This function is only available on Linux.

◆ fromHresult()

SystemError Qx::SystemError::fromHresult ( HRESULT res,
QString aError = u"System Error"_s )
static

Returns a system error based on the HRESULT res and with the action error aError.

The error's value is set directly to the value of res, while it's cause() will contain a string representation of the value.

Note
This function is only available on Windows.

◆ fromNtStatus()

SystemError Qx::SystemError::fromNtStatus ( NTSTATUS res,
QString aError = u"System Error"_s )
static

Returns a system error based on the NTSTATUS res and with the action error aError.

The error's value is set directly to the value of res, while it's cause() will contain a string representation of the value.

Note
This function is only available on Windows.

◆ isValid()

bool Qx::SystemError::isValid ( ) const

Returns true if the system error value is greater than 0; otherwise, returns false.

See also
code().

◆ originalFormat()

SystemError::OriginalFormat Qx::SystemError::originalFormat ( ) const

Returns the original format of the system error, which when known can be used to further dissect the error's value for more system specific error information.

See also
value().

◆ value()

quint32 Qx::SystemError::value ( ) const

Returns the original value of the system error.

The value of this code is system dependent and varies from facility to facility.

See also
cause().

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