org.rythmengine.exception.CompileException:未处理的异常类型异常

时间:2016-05-15 15:14:20

标签: rythm

通过http://fiddle.rythmengine.com/#/editor

上的Rythm引擎小提琴试用下面的rythm模板代码时

我收到错误:

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

我试过的模板是:

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

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

我通过文档查看某种try / catch构造并咨询了我最喜欢的搜索引擎。我没有找到如何处理异常的提示。

如何在Rythm模板代码中处理异常?

1 个答案:

答案 0 :(得分:-1)

您需要确保不丢弃已检查的异常。将您的代码更改为:

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

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

它应该可行

相关问题