exceptions.h

Go to the documentation of this file.
00001 
00023 #ifndef EXCEPTIONS_H
00024 #define EXCEPTIONS_H
00025 
00026 #define eThrow(ExceptionClass, details) (throw (ExceptionClass(details, __FILE__, __LINE__)))
00027 
00028 class Exception
00029 {
00030         public:
00031                 Exception() {};
00032                 Exception(const QString& description, const QString& details, const char* file, int line) 
00033                 {
00034                         m_details = details; 
00035                         m_description = description;
00036                         m_file = file;
00037                         m_line = line;
00038                 }
00039                 static void msgBox(QWidget* widget, const QString& description, const QString& details, const char* file = "", int line = 0)
00040                 {
00041                         if (file != "" && line != 0)
00042                                 qDebug() << "Exception thrown in " << file << " at line " << line;
00043 
00044                         QMessageBox msg(widget);
00045                         msg.setWindowTitle("LCDBuilder");
00046                         msg.setWindowIcon(QIcon(":/lcdbuilder_icon.png"));
00047                         msg.setIcon(QMessageBox::Warning);
00048                         msg.setInformativeText(description);
00049                         msg.setDetailedText(details);
00050                         msg.exec();
00051                 }
00052                 QString details() const { return m_details; }
00053                 QString description() const { return m_description; }
00054                 const char* file() const { return m_file; }
00055                 int line() const { return m_line; }
00056 
00057         private:
00058                 QString m_details;
00059                 QString m_description;
00060                 const char* m_file;
00061                 int m_line;
00062 };
00063 
00065 class UnsupportedException : public Exception
00066 {
00067         public:
00068                 UnsupportedException(const QString& details, const char* file = "", int line = 0) 
00069                         : Exception("File format / feature / operation not supported", details, file, line) {}
00070 };
00071 
00073 class HardwareUnavailableException : public Exception
00074 {
00075         public:
00076                 HardwareUnavailableException(const QString& details, const char* file = "", int line = 0) 
00077                         : Exception("Sorry, but the hardware is either unavailable, or not responding", details, file, line) {}
00078 };
00079 
00081 class AccessFailureException : public Exception
00082 {
00083         public:
00084                 AccessFailureException(const QString& details, const char* file = "", int line = 0) 
00085                         : Exception("Attempt to access resource failed", details, file, line) {}
00086 };
00087 
00089 class InvalidDataException : public Exception
00090 {
00091         public:
00092                 InvalidDataException(const QString& details, const char* file = "", int line = 0) 
00093                         : Exception("The data currently processed is invalid", details, file, line) {}
00094 };
00095 
00097 
00098 class InternalException : public Exception
00099 {
00100         public:
00101                 InternalException(const QString& details, const char* file = "", int line = 0) 
00102                         : Exception("Internal error occured, that should never happend please contact the author", details, file, line) {}
00103 };
00104 
00105 #endif

Generated on Thu Apr 5 13:06:31 2007 for LCDBuilder by  doxygen 1.4.7