| 15 | } |
| 16 | |
| 17 | float ratio_wrapper(float a, float b) |
| 18 | { |
| 19 | try{ |
| 20 | return ratio(a, b); |
| 21 | } |
| 22 | catch(int eid) |
| 23 | { |
| 24 | if (eid == 1) |
| 25 | std::cerr << "Call ratio() failed: the 1st argument should be positive." << std::endl; |
| 26 | else if (eid == 2) |
| 27 | std::cerr << "Call ratio() failed: the 2nd argument should be positive." << std::endl; |
| 28 | else |
| 29 | std::cerr << "Call ratio() failed: unrecognized error code." << std::endl; |
| 30 | } |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | int main() |
| 35 | { |