MyStatement concept should "throw an exception"

Hi MPS Pros,

when writing throw new Exceptin() in a InstanceMethod,
one get s the errormessage "Error: uncaught Exceptions: Exception"

i have concept MyStatement which extends Statement. The MyStatement can throw an Exception in the generated code. I already checked the code of the ThrowStatement but did not figure out how i can get the errormessage to appear..

Any hints?
Dan

My Code

public boolean isGuardClauseStatement()
  overrides Statement.isGuardClauseStatement {
  true;
}   
            
public void collectUncaughtMethodThrowables(set<node<Classifier>> throwables, boolean ignoreMayBeThrowables)
  overrides Statement.collectUncaughtMethodThrowables {
  node<Expression> exp = <new Exception()>;
  if (!(ignoreMayBeThrowables)) {
    Statement.collectUncaughtMethodThrowables(throwables, exp);
  }
     
  throwables.add(exp.type : ClassifierType.classifier);
     
}
            <table width="100%" cellspacing="0" border="0"><tbody><tr><td align="left"><table width="80%" cellspacing="5" cellpadding="0" border="0"><tbody><tr><td><table width="100%" cellspacing="0" cellpadding="0" border="0"><tbody> <tr><td><div>This is a very simple Question</div></td></tr> <tr><td><ul> <li>Yes, indeed</li> <li>No, defenitelly not</li> </ul></td></tr> <tr><td></td></tr> </tbody></table></td></tr></tbody></table></td></tr></tbody></table>
1 comment
There is a checking rule checkThrowedByThrowIsCaught for the ThrowStatement. At the end you can find this method call: RulesFunctions_BaseLanguage.check(throwables, throwStatement). You simply have to pass a set of exceptions that is thrown by your statement. Everything else if done by this method.

Example:
When your statement throws an IOException, create a checking rule like this:
checking rule check_ThrowIoExcpetion {
  applicable for concept = ThrowIoException as statement
  overrides false

  do {
    set<node<Type>> throwables = new hashset<node<Type>>;
    throwables.add(<IOException>);
    RulesFunctions_BaseLanguage.check(throwables, statement);
  }
}
prettyPrint();
0

Please sign in to leave a comment.