Unearthing Lift's Buried Exceptions

10 views
Skip to first unread message

Anders Johansen

unread,
Apr 8, 2010, 12:18:07 PM4/8/10
to Lift

hi,

In the sample below, "hi" is a simple view that has a problem in that
it has infinite recursion and so throws an exception. By default, if
I call buriedHi, I get no exceptions. If I call unearthedHi the
exception is shown.

Is there some way to configure lift to implicitly have the behavior of
unearthedHi without having to wrap everything in a try/catch block?
(Yes, I know that using closures that try/catch can be reduced to a
simple function call but would still rather not have to do that for
all views.) Also, it seems like Lift is burying exceptions elsewhere
too but I cannot say so for sure.

class foo extends InsecureLiftView {

def hi: NodeSeq = <html>{ hi }</html>

def buriedHi: NodeSeq = hi

def unearthedHi: NodeSeq = try { hi } catch { case t:Throwable =>
t.printStackTrace; <html><body>stack trace found</body></html> }
}

thank you


Marius

unread,
Apr 8, 2010, 12:26:21 PM4/8/10
to Lift
Lift doesn't really buries exceptions. You can use
LiftRules.exceptionHandler that will be called for uncaught exceptions
hence handle them from a central place. Also if you don't like try/
catch you can use Lift's tryo stuff from ControlHelpers.

Br's,
Marius

Timothy Perrett

unread,
Apr 8, 2010, 12:38:46 PM4/8/10
to lif...@googlegroups.com
I tend to use tryo all the time and handle stuff as Box(s) - even if you get chained exceptions then you can map/match it out and handle appropriately. Boiling up to LiftRules.exceptionHandler tends to be like a last catch all for me.

Cheers, Tim

> --
> You received this message because you are subscribed to the Google Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
>
>

Anders Johansen

unread,
Apr 8, 2010, 2:54:30 PM4/8/10
to Lift

Thank you for the quick responses!

However, I think something is catching and burying the exception
before it can get to the LiftRules.exceptionHandler handlers.

I've looked through the Lift code and it looks like the default
handler will report exceptions, whereas mine is not. Furthermore, I
have tried manually defining my own exceptionHandler in a number of
different ways and they do not get invoked.

I've also tried throwing Exceptions instead of Errors (the Throwable
that led me to this problem was actually an Error, StackOverflowError)
but these Exceptions seem to be buried as well.

There is also nothing in the logs. My Boot.scala is very bare.

I am running Lift 2.0-M4.

Is there anything else in the Lift framework that might be catching
exceptions before the LiftRules.exceptionHandler handlers get invoked?

thank you

David Pollak

unread,
Apr 8, 2010, 3:04:39 PM4/8/10
to lif...@googlegroups.com
This looks like a bug to me... it looks like we're treating views differently from snippets for exception purposes.

Please open a ticket at http://ticket.liftweb.net and we'll get a fix into M5

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

Anders Johansen

unread,
Apr 8, 2010, 3:36:25 PM4/8/10
to Lift

I created an account on assembla named "dimensia". I think I am
lacking permissions to create a new ticket though, as there is no
option to create a new ticket for me at http://ticket.liftweb.net
(although I can browse all the existing tickets with no apparent
problems).

thank you

Ross Mellgren

unread,
Apr 8, 2010, 3:38:42 PM4/8/10
to lif...@googlegroups.com
You must "watch" the liftweb space to file tickets.

-Ross

Anders Johansen

unread,
Apr 8, 2010, 3:47:06 PM4/8/10
to Lift
Reply all
Reply to author
Forward
0 new messages