UI 中的 Guidewire 异常处理

Guidewire Exception handling in UI

当内部 Guidewire 代码抛出异常时,您会收到一个格式正确的错误消息框。但是,当自定义代码抛出异常时,您将被定向到错误页面(带有红色堆栈跟踪文本和返回应用程序按钮)。 Guidewire 框架中是否有任何东西可以更好地 UI 正确处理错误?

如:

//someMethod code...
try{
    return user.someOtherCode()
}catch(e : Exception){
    //TODO: gracefully display erorr mesage on page
    //e.g.   showErrorMessage()
    return null
}

通过 Guidewire OOTB 代码进行一些搜索后,UserDisplayableExceptions 就是您所需要的 - 回答我自己,以防其他人有这种想法。

function goToPolicy(bulkDocumentDownload : BulkDocDownload_Avi) {
  try {
    throw new IndexOutOfBoundsException("Ops! some index out of bounds exception was thrown")
  } catch (e : Exception) {
    throw new com.guidewire.pl.web.controller.UserDisplayableException(e.Message)
  }
}

你有一个更简单的方法,

下面的代码可以用助手 class 或任何增强功能编写,甚至可以在 PCF 代码选项卡中编写,这将 return 一个很好的格式化错误消息。

gw.api.util.LocationUtil.addRequestScopedErrorMessage("你的错误信息")