On Jul 10, 11:11 pm, Jeppe Nejsum Madsen <[email protected]> wrote:
> Hi,
>
> I understand (I think :-) the use of Option/Box to avoid the common
> NPE. Also that map/for gives a nice way to conditionally do stuff with
> something that can be Empty.
>
> But sometimes the Box just have to be full and if it isn't, this is a
> logic error that is better handled than silently ignored.

val myBox: Box[SomeType] = ...

myBox or (alternative-logic)

The or function returns the Box content if the Box is full or the
result of the alternative-logic expression if the Box is Empty or
Failure for that matter.

You can also pattern match such as

myBox match {
 case Full(x) =>
 case Failure(msg,ex,chain) => handle the Failure if you need to
 case _ => handle Empty here
}

>
> So what is a good pattern for doing this?
>
> On a related note: Is there a way to (globally) catch exceptions/errors that 
> shows up in a Lift app?
>
> I foundhttp://wiki.liftweb.net/index.php/HowTo_use_error_pagesbut this
> doesn't seem up to date....

Please see LiftRules.exceptionHandler ... yeah I need to update that
wiki.

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

Reply via email to