[英]Custom lexer Error Message in JavaCC
I want to customize the lexer error message, I have my exception class that subclasses TokenMgrError and redefined the function but how do I ensure that in Lexer2TokenManager class, that it will do 我想自定义lexer错误消息,我有一个异常类,该类将TokenMgrError子类化,并重新定义了该函数,但是如何确保在Lexer2TokenManager类中它将执行此操作
throw new mysubclassexception(.........)
instead of 代替
throw new TokenMgrError(.......)
Could the documentation that the comments refer to be out of date? 注释所引用的文档可能过时了吗?
Whenever I want to use a custom exception class I insert a try / catch block in my production rules. 每当我想使用自定义异常类时,都会在生产规则中插入try / catch块。 Something along the lines of this;
与此类似的东西;
(
...
{
try {
...
} catch (Exception e) {
...
throw new MyCustomException ( e, customMessage );
}
}
)
Perhaps not the most elegant solution but it has always been adequate for me. 也许这不是最优雅的解决方案,但对我而言一直足够。 Hope it helps.
希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.