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?

My Code

public boolean isGuardClauseStatement()
  overrides Statement.isGuardClauseStatement {
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);
1 comment
Comment actions Permalink
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.

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>>;
    RulesFunctions_BaseLanguage.check(throwables, statement);

Please sign in to leave a comment.