Is there a way to include, at the document level, the ability to raise an exception when specific conditions occur?
Example
<<if [cliente.numeroAbitanti > 1000 ]>>
<<throw "Number xxxx is too high">>
<<endif>>
Is there a way to include, at the document level, the ability to raise an exception when specific conditions occur?
Example
<<if [cliente.numeroAbitanti > 1000 ]>>
<<throw "Number xxxx is too high">>
<<endif>>
There is no special tag to achieve this. However, this can be easily done using a static method of a custom type defined in your code like this:
public class Util
{
// The method must have a return type.
public static Object throwException(String message)
{
throw new RuntimeException(message);
}
}
LINQ Reporting Engine should be made aware of the class before using it in a template as follows:
ReportingEngine engine = new ReportingEngine();
engine.getKnownTypes().add(Util.class);
engine.buildReport(...);
Then, the method can be used to throw an exception upon a condition defined in a template like so:
<<if [cliente.numeroAbitanti > 1000]>>
<<[Util.throwException("Number xxxx is too high")]>>
<</if>>