2016-05-15 140 views
0

当通过节奏引擎小提琴在http://fiddle.rythmengine.com/#/editororg.rythmengine.exception.CompileException:未处理的异常类型异常

下面尝试的节奏模板代码中,我得到的错误:

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

你需要确保你不会丢掉检查的异常。你的代码更改为:

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

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

,它应该工作

+0

这仅仅是一个例子。如果我不能更改我的代码呢? –

+0

以及我看不到任何理由支持模板代码中的CheckedException。但如果你有一个很好的理由,我可以考虑改变行为 –