0

when internal Guidewire code throws an exception you get a nicely formatted error message box. However, when custom code throws an exception you are directed to the error page (with the red stack trace text & back to application button). Is there anything in the Guidewire framework to make proper UI handling of errors nicer?

such as: < TextBox value="user.someMethod()"/>

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

2 Answers2

1

You have a simpler way to do this,

The below piece of code can be written in helper class or any Enhancement or even in PCF code tab, this will return a nice formatted error message.

gw.api.util.LocationUtil.addRequestScopedErrorMessage("Your error message")

Arun Kumar Mani
  • 337
  • 2
  • 7
  • Can It block the binding? Or If we add an error message in this addRequestScopedError method it will just throw the error message but will allow to bind. – Pallab Feb 01 '23 at 06:04
0

After some searching through Guidewire OOTB code UserDisplayableExceptions are what you need - answering myself in case someone else has this thought.

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)
  }
}
bodovix
  • 299
  • 2
  • 4
  • 11