source:
tests/exceptions/data-except.cfa
@
7f2bfb7
Last change on this file since 7f2bfb7 was fe0b94f, checked in by , 14 months ago | |
---|---|
|
|
File size: 774 bytes |
Rev | Line | |
---|---|---|
[e68d092] | 1 | // Test exceptions that add data but no functionality. |
2 | ||
[fe0b94f] | 3 | #include <fstream.hfa> |
[3bf9d10] | 4 | |
[d00d581] | 5 | exception paired { |
[e68d092] | 6 | int first; |
7 | int second; | |
[d00d581] | 8 | }; |
[e68d092] | 9 | |
[d00d581] | 10 | vtable(paired) paired_vt; |
[e68d092] | 11 | |
[ecfd758] | 12 | const char * virtual_msg(paired * this) { |
13 | return this->virtual_table->msg(this); | |
[e68d092] | 14 | } |
15 | ||
16 | int main(int argc, char * argv[]) { | |
[ecfd758] | 17 | paired except = {&paired_vt, 3, 13}; |
[e68d092] | 18 | |
19 | try { | |
[046a890] | 20 | throw except; |
[e68d092] | 21 | } catch (paired * exc) { |
[3bf9d10] | 22 | sout | virtual_msg(exc) | '(' | exc->first | ", " | exc->second | ')'; |
[e68d092] | 23 | ++exc->first; |
24 | } | |
25 | ||
[3bf9d10] | 26 | sout | virtual_msg(&except) | '(' | except.first | ", " | except.second | ')'; |
[e68d092] | 27 | |
28 | try { | |
[046a890] | 29 | throwResume except; |
[e68d092] | 30 | } catchResume (paired * exc) { |
[3bf9d10] | 31 | sout | virtual_msg(exc) | '(' | exc->first | ", " | exc->second | ')'; |
[e68d092] | 32 | ++exc->first; |
33 | } | |
34 | ||
[3bf9d10] | 35 | sout | virtual_msg(&except) | '(' | except.first | ", " | except.second | ')'; |
[e68d092] | 36 | } |
Note: See TracBrowser
for help on using the repository browser.