openArchitectureWare

Other than model checks (.chk) files, OAW provides the ERROR definition to inform the developer that something bad has happened:

«ERROR "Your message goes here"»

The problem with this is that OAW does not show or tell you where this exception occured; it only prints out the error message to System.err.

However, based on this forum post, it’s possible to throw exceptions within OAW templates:

«throwException("Your message goes here")»

The output now displays the backtrace, allowing you to identify where the exception occured:

SEVERE: Error in Component  of type org.openarchitectureware.xpand2.Generator: 
	EvaluationException : java.lang.RuntimeException: Your message goes here
	template::Template.xpt[1993,25] on line 60 'throwException("Your message goes here")'               
	template::Template.xpt[445,41] on line 21 'EXPAND expandSitemapPage FOREACH children'
	[23,41] on line 1 'EXPAND template::Template::main FOR model'

Implementation

In order to implement this, simply add this to your extensions (.ext) file:

String throwException(String message) :
	JAVA org.company.OawCodeGenerator.throwException(java.lang.String);

Create this method in org.company.OawCodeGenerator:

public static void throwException(String message) {
  throw new RuntimeException(message);
}

(Related IAML issue: Issue 155)