Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exception Handling – illustrated by Java mMIC-SFT November 2003 Anders P. Ravn Aalborg University.

Similar presentations


Presentation on theme: "Exception Handling – illustrated by Java mMIC-SFT November 2003 Anders P. Ravn Aalborg University."— Presentation transcript:

1 Exception Handling – illustrated by Java mMIC-SFT November 2003 Anders P. Ravn Aalborg University

2 An exception handler try { /* block of code – domain of the handler */ c_obj.m();... } catch (MyException ex){ /* block of code – handler for ex of class MyException */... } catch (...) {... block of code }... } finally {... block of code }

3 Throwing an Exception try {... block of code c_obj.m(); } catch (MyException ex){... } class C { void m() {... throw new MyException(”bad”,10); } c_obj = new C();

4 Declaring an Exception public class MyException extends Exception... public MyException(string s, int n){... }

5 Recovery blocks ENSURE acceptance_test BY { module_1 } ELSE BY { module_2 }... ELSE BY { module_m } ELSE ERROR BW p. 120


Download ppt "Exception Handling – illustrated by Java mMIC-SFT November 2003 Anders P. Ravn Aalborg University."

Similar presentations


Ads by Google