First you have to create a TagLib as below:
With following contents:
And use of try-catch as below:
With following contents:
package com.pkm.taglib class TryCatchTagLib { static namespace = "ui" def Try = { attrs, body -> try { out << body() request.exception = null } catch (Throwable e) { request.exception = e } } def Catch = { attrs, body -> if (request.exception) { out << body(exception: request.exception) request.exception = null } } }
And use of try-catch as below:
<ui:try> SOME WORK I AM TRYING </ui:try> <ui:catch> GOT EXCEPTION=${exception} </ui:catch>