org.rythmengine.exception.CompileException: Unhandled exception type Exception

129 Views Asked by At

When trying out the rythm template code below via the Rythm engine fiddle at http://fiddle.rythmengine.com/#/editor

I get the error:

org.rythmengine.exception.CompileException: Unhandled exception type Exception

the template I tried is:

 @{
        class Field {
           String description;
           String getDescription() throws Exception {
              return description;
           }
        }
        Field field=new Field();
        field.description="test";
    }

the field description is: @(field.getDescription())

I have looked thru the documentation for some kind of try/catch construct and consulted my favorite search engine. I didn't find a hint on how to handle exceptions.

How are exceptions to be handled in Rythm template code?

1

There are 1 best solutions below

2
On

You need to make sure you do NOT throw out checked exception. Change your code to :

@{
        class Field {
           String description;
           String getDescription() throws RuntimeException {
              return description;
           }
        }
        Field field=new Field();
        field.description="test";
    }

the field description is: @(field.getDescription())

And it should work