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);
}
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);
}
Please sign in to leave a comment.
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); } }