| 1 | %include <std/std_except.i> |
| 2 | %include <std_string.i> |
| 3 | |
| 4 | %{ |
| 5 | #include <stdexcept> |
| 6 | %} |
| 7 | |
| 8 | |
| 9 | |
| 10 | namespace std { |
| 11 | /* |
| 12 | Mark all of std exception classes as "exception classes" via |
| 13 | the "exceptionclass" feature. |
| 14 | |
| 15 | If needed, you can disable it by using %noexceptionclass. |
| 16 | */ |
| 17 | %exceptionclass exception; |
| 18 | %exceptionclass bad_exception; |
| 19 | %exceptionclass logic_error; |
| 20 | %exceptionclass domain_error; |
| 21 | %exceptionclass invalid_argument; |
| 22 | %exceptionclass length_error; |
| 23 | %exceptionclass out_of_range; |
| 24 | %exceptionclass runtime_error; |
| 25 | %exceptionclass range_error; |
| 26 | %exceptionclass overflow_error; |
| 27 | %exceptionclass underflow_error; |
| 28 | } |
| 29 | |
| 30 | |
| 31 | namespace std { |
| 32 | struct exception |
| 33 | { |
| 34 | virtual ~exception() throw(); |
| 35 | virtual const char* what() const throw(); |
| 36 | }; |
| 37 | |
| 38 | struct bad_exception : exception |
| 39 | { |
| 40 | }; |
| 41 | |
| 42 | struct logic_error : exception |
| 43 | { |
| 44 | logic_error(const string& msg); |
| 45 | }; |
| 46 | |
| 47 | struct domain_error : logic_error |
| 48 | { |
| 49 | domain_error(const string& msg); |
| 50 | }; |
| 51 | |
| 52 | struct invalid_argument : logic_error |
| 53 | { |
| 54 | invalid_argument(const string& msg); |
| 55 | }; |
| 56 | |
| 57 | struct length_error : logic_error |
| 58 | { |
| 59 | length_error(const string& msg); |
| 60 | }; |
| 61 | |
| 62 | struct out_of_range : logic_error |
| 63 | { |
| 64 | out_of_range(const string& msg); |
| 65 | }; |
| 66 | |
| 67 | struct runtime_error : exception |
| 68 | { |
| 69 | runtime_error(const string& msg); |
| 70 | }; |
| 71 | |
| 72 | struct range_error : runtime_error |
| 73 | { |
| 74 | range_error(const string& msg); |
| 75 | }; |
| 76 | |
| 77 | struct overflow_error : runtime_error |
| 78 | { |
| 79 | overflow_error(const string& msg); |
| 80 | }; |
| 81 | |
| 82 | struct underflow_error : runtime_error |
| 83 | { |
| 84 | underflow_error(const string& msg); |
| 85 | }; |
| 86 | } |
| 87 | |