Building own try/catch


guess this is a more difficult question to answer .. hope there is still an (easy) solution available :)

(1) I have a concept MyStatementList extending StatementList.
(2) I can use MyStatementList in a simple java class

     MyStatementList {
        FileInputStream f = new FileInputStream("dan");

(3) Of course, MPS will now mark the 'new FileInputStream("  ")' with
    'uncaught Excpetion ""'

(4) I will catch that exception in the code-generator. So how can i add some support to
    MyStatementList in order to mark the Exception as catched?

I guess this is not easily possible. I checked the try/catch ... lots of code ...

Comment actions Permalink
Add the interfaces IMethodLike and IStatementListContainer to your concept and implement the required behavior methods as follows
public node<StatementList> getBody() 
  overrides IMethodLike.getBody { 
public node<> getExpectedRetType() 
  overrides IMethodLike.getExpectedRetType { 
public nlist<Type> getThrowableTypes() 
  overrides IMethodLike.getThrowableTypes { 
  new nlist<Type>; 
public boolean implicitThrows() 
  overrides IMethodLike.implicitThrows { 

If you want to catch specific exceptions only remove the method implicitThrows and return the exception types in getThrowableTypes
Comment actions Permalink
nice solution! thanks,

Please sign in to leave a comment.