35 lines
1.0 KiB
C++
35 lines
1.0 KiB
C++
|
|
#ifndef ERROR_DIALOG_H
|
||
|
|
#define ERROR_DIALOG_H
|
||
|
|
|
||
|
|
#include <QErrorMessage>
|
||
|
|
#include <QObject>
|
||
|
|
#include <QString>
|
||
|
|
|
||
|
|
class ErrorDialog : private QObject {
|
||
|
|
// For translation
|
||
|
|
Q_OBJECT
|
||
|
|
|
||
|
|
public:
|
||
|
|
// Method to dispose the error dialog
|
||
|
|
static void displayError(QWidget *parent, const QString &errorMsg);
|
||
|
|
|
||
|
|
ErrorDialog() = delete;
|
||
|
|
|
||
|
|
private:
|
||
|
|
// A method for initializing the error dialog
|
||
|
|
static QErrorMessage *getDialog(QWidget *parent, const QString &errorMsg);
|
||
|
|
|
||
|
|
// A method for obtaining a "human-readable" text based on an error code
|
||
|
|
static QString getDetailedMessage(int errorCode);
|
||
|
|
|
||
|
|
// Methods for handling various SQL constraints
|
||
|
|
static QString handleNotFoundErrors(const QString &errorMsg);
|
||
|
|
static QString handleCheckConstraint(const QString &errorMsg);
|
||
|
|
static QString handleForeignKeyConstraint(const QString &errorMsg);
|
||
|
|
static QString handlePrimaryKeyConstraint();
|
||
|
|
static QString handleSqlConstraints(const QString &errorMsg);
|
||
|
|
static QString handleUniqueConstraint(const QString &errorMsg);
|
||
|
|
};
|
||
|
|
|
||
|
|
#endif // ERROR_DIALOG_H
|