Brian Carlstrom | 33f741e | 2011-10-03 11:24:05 -0700 | [diff] [blame^] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | import java.io.IOException; |
| 3 | |
| 4 | public class ExceptionHandle { |
| 5 | int f() throws Exception { |
| 6 | try { |
| 7 | g(1); |
| 8 | } catch (IOException e) { |
| 9 | return 1; |
| 10 | } catch (Exception e) { |
| 11 | return 2; |
| 12 | } |
| 13 | try { |
| 14 | g(2); |
| 15 | } catch (IOException e) { |
| 16 | return 3; |
| 17 | } |
| 18 | return 0; |
| 19 | } |
| 20 | void g(int doThrow) throws Exception { |
| 21 | if (doThrow == 1) { |
| 22 | throw new Exception(); |
| 23 | } else if (doThrow == 2) { |
| 24 | throw new IOException(); |
| 25 | } |
| 26 | } |
| 27 | } |