On Thu, Dec 24, 2009 at 6:14 PM, Xuefeng Wu <ben...@gmail.com> wrote:
> It's helpful, thank you! > > > On Thu, Dec 24, 2009 at 7:03 PM, Marius <marius.dan...@gmail.com> wrote: > >> If you want a popup a dialog when an exception is thrown from an Ajax >> function you can do something like: >> >> import net.liftweb.http.js._ >> import net.liftweb.http.js.jquery._ >> import JqJsCmds._ >> ... >> >> LiftRules.exceptionHandler.prepend { >> case (mode, req, ex) => JavaScriptResponse(ModalDialog(<p>Crap >> it failed.</p>)) >> } >> > I think the signature for an Ajax request would be: val AjaxRequestPrefix = LiftRule.ajaxPath case (mode, Req(AjaxRequestPrefix :: _, _, PostRequest), ex) => ... > >> You can make you own logic to distinguish between exceptions thrown >> from Ajax requests or from snippet, either by some information from >> Req or some additional information from the exception itself or by >> some other means. >> >> Br's, >> Marius >> >> On Dec 24, 11:15 am, Xuefeng Wu <ben...@gmail.com> wrote: >> > Hi, >> > I have a question about exception handle in Lift. >> > >> > *How could I pop a error dialog except redirect?* >> > * >> > * >> > *Lift have LiftRules.exceptionHandler.prepend to handle exception.* >> > LiftRules.exceptionHandler.prepend { >> > case (mode, state, ex) => RedirectResponse("/error") >> > // how could I pop a error dialog? >> > } >> > >> > And I found that Lift could handle exception from snippet , for example: >> > def throwExceptionB(in: NodeSeq): NodeSeq = { >> > throw new RuntimeException("throw exception") >> > a(() => {Alert("Text throw exception")}, >> > Text("throw exception") >> > ) >> > } >> > >> > But I find lift didn't throw exception if it rise from lift inside: >> > def throwExceptionB(in: NodeSeq): NodeSeq = { >> > a(() => {throw new RuntimeException("throw exception");Alert("Test >> throw >> > exception")}, >> > Text("throw exception") >> > ) >> > } >> > The exception will be printed at server side but not the client. >> > I think Lift should also could handle it. >> > >> > -- >> > Scala中文社区: http://groups.google.com/group/scalacn >> >> -- >> >> You received this message because you are subscribed to the Google Groups >> "Lift" group. >> To post to this group, send email to lift...@googlegroups.com. >> To unsubscribe from this group, send email to >> liftweb+unsubscr...@googlegroups.com<liftweb%2bunsubscr...@googlegroups.com> >> . >> For more options, visit this group at >> http://groups.google.com/group/liftweb?hl=en. >> >> >> > > > -- > Scala中文社区: http://groups.google.com/group/scalacn > > -- > You received this message because you are subscribed to the Google Groups > "Lift" group. > To post to this group, send email to lift...@googlegroups.com. > To unsubscribe from this group, send email to > liftweb+unsubscr...@googlegroups.com<liftweb%2bunsubscr...@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 -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.