]>
Commit | Line | Data |
---|---|---|
58ee6135 RC |
1 | /* |
2 | * Copyright (c) 2001, Robert Collins. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * A copy of the GNU General Public License can be found at | |
10 | * http://www.gnu.org/ | |
11 | * | |
12 | * Written by Robert Collins <rbtcollins@hotmail.com> | |
13 | * | |
14 | */ | |
15 | ||
c93bc6d0 MB |
16 | #ifndef SETUP_EXCEPTION_H |
17 | #define SETUP_EXCEPTION_H | |
18 | ||
58ee6135 | 19 | #include <exception> |
08678720 | 20 | #include <string> |
072fb49a | 21 | #include <typeinfo> |
072fb49a | 22 | #include "msg.h" |
58ee6135 | 23 | |
666bf37d | 24 | class Exception : public std::exception { |
58ee6135 RC |
25 | public: |
26 | Exception (char const *where, char const *message, int appErrNo = 0); | |
08678720 | 27 | Exception (char const *where, const std::string& message, int appErrNo = 0); |
072fb49a | 28 | ~Exception () throw() {}; |
666bf37d | 29 | char const *what() const throw(); |
58ee6135 RC |
30 | int errNo() const; |
31 | private: | |
08678720 | 32 | std::string _message; |
58ee6135 RC |
33 | int appErrNo; |
34 | }; | |
35 | ||
58ee6135 RC |
36 | #define APPERR_CORRUPT_PACKAGE 1 |
37 | #define APPERR_IO_ERROR 2 | |
ead15931 | 38 | #define APPERR_LOGIC_ERROR 3 |
27820085 | 39 | #define APPERR_WINDOW_ERROR 4 |
58ee6135 | 40 | |
703f1a44 | 41 | #define TOPLEVEL_CATCH(owner, threadname) \ |
072fb49a MB |
42 | catch (Exception *e) \ |
43 | { \ | |
703f1a44 | 44 | fatal((owner), IDS_UNCAUGHT_EXCEPTION_WITH_ERRNO, (threadname), \ |
072fb49a MB |
45 | typeid(*e).name(), e->what(), e->errNo()); \ |
46 | } \ | |
47 | catch (std::exception *e) \ | |
48 | { \ | |
703f1a44 | 49 | fatal((owner), IDS_UNCAUGHT_EXCEPTION, (threadname), \ |
072fb49a MB |
50 | typeid(*e).name(), e->what()); \ |
51 | } | |
52 | ||
53 | ||
c93bc6d0 | 54 | #endif /* SETUP_EXCEPTION_H */ |