Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QCoreApplication>
- #include <QDebug>
- #include <QException>
- int main(int argc, char *argv[])
- {
- QCoreApplication a(argc, argv);
- int arr[10];
- try
- {
- arr[11] = 30;
- }
- catch (const std::out_of_range& e)
- {
- qDebug() << "Exception out of range occurred ..." << e.what();
- }
- catch (...)
- {
- qDebug() << "Unknown Exception occured...";
- }
- return a.exec();
- }
- #include <QCoreApplication>
- #include <QDebug>
- #include <QException>
- class testException : public QException
- {
- public:
- testException(QString const& message) :
- message(message)
- {}
- virtual ~testException()
- {}
- void raise() const { throw *this; }
- testException *clone() const { return new testException(*this); }
- QString getMessage() const {
- return message;
- }
- private:
- QString message;
- };
- int main(int argc, char *argv[])
- {
- QCoreApplication a(argc, argv);
- try
- {
- // throw std::out_of_range("blah");
- throw testException("blah");
- }
- catch (const std::out_of_range& e)
- {
- qDebug() << "Exception out of range occurred ...";
- }
- catch (...)
- {
- qDebug() << "Unknown Exception occured...";
- }
- return a.exec();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement