Exception-handling in LiftServlet.runAjax

43 views
Skip to first unread message

Andreas Joseph Krogh

unread,
Oct 18, 2022, 6:13:20 AM10/18/22
to lif...@googlegroups.com

Hi, in runAjax we have this:

case e: Exception => S.runExceptionHandlers(requestState, e)

 

And S.runExceptionHandlers takes in Throwable:

 

def runExceptionHandlers(req: Req, orig: Throwable): Box[LiftResponse] = {

I know that “best practice” is to catch Exception and not Throwable or Error, but in real life f.eg. NoSuchMethodError can occur, and should be handled to give nice error-messages (handled in installed Exception-handlers), instead of the application just shutting down or silently not working.

 

Anyone up for changing this in LiftServlet.runAjax to catch Throwable?

 

--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963

Carlos Saltos

unread,
Jan 10, 2023, 9:00:55 AM1/10/23
to Lift
At my company we handling exceptions calling to LiftRules.exceptionHandler.prepend at Boot.scala but this works only for normal HTTP requests, for Ajax, we create our own lift.js file copying the original code and changing the error handling part to our own.

You may find the original lift.js at the Lift classpath.

Best regards,

Carlos
Reply all
Reply to author
Forward
0 new messages