Have you tried using in boot LiftRules.exceptionHandler.prepend
(...)  ?

Br's,
Marius

On Dec 21, 11:43 pm, tiro <[email protected]> wrote:
> Hi,
>
> just wondering if anybody knows of a handy way to properly handle the
> exceptions that are thrown when a user uploads a file that exceeds the
> size limit (or who knows what else can happen)?
>
> The stack trace that I see in such a case is as follows -- and apart
> from trying S.addAround I don't see a any place where one could insert
> some exception handling:
>
> Message: org.apache.commons.fileupload.FileUploadBase
> $SizeLimitExceededException: the request was rejected because its size
> (7385713) exceeds the configured maximum (6291456)
>         org.apache.commons.fileupload.FileUploadBase
> $FileItemIteratorImpl.<init>(FileUploadBase.java:914)
>         org.apache.commons.fileupload.FileUploadBase.getItemIterator
> (FileUploadBase.java:331)
>
> org.apache.commons.fileupload.servlet.ServletFileUpload.getItemIterator
> (ServletFileUpload.java:148)
>         net.liftweb.http.provider.servlet.HTTPRequestServlet$$anon$1.<init>
> (HTTPRequestServlet.scala:110)
>         net.liftweb.http.provider.servlet.HTTPRequestServlet.extractFiles
> (HTTPRequestServlet.scala:100)
>         net.liftweb.http.Req$$anonfun$5.apply(Req.scala:182)
>         net.liftweb.http.Req$$anonfun$5.apply(Req.scala:156)
>         net.liftweb.http.Req.x$17(Req.scala:351)
>         net.liftweb.http.Req.uploadedFiles(Req.scala:350)
>         net.liftweb.http.LiftSession.runParams(LiftSession.scala:306)
>         net.liftweb.http.LiftSession.processRequest(LiftSession.scala:492)
>         net.liftweb.http.LiftServlet.net$liftweb$http$LiftServlet$
> $dispatchStatefulRequest(LiftServlet.scala:261)
>         net.liftweb.http.LiftServlet$$anonfun$3.apply(LiftServlet.scala:171)
>         net.liftweb.http.LiftServlet$$anonfun$3.apply(LiftServlet.scala:171)
>         net.liftweb.http.S$.net$liftweb$http$S$$wrapQuery(S.scala:974)
>         net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_nest2InnerInit$1$
> $anonfun$apply$25.apply(S.scala:1114)
>         net.liftweb.http.S$.net$liftweb$http$S$$doAround(S.scala:911)
>         net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_nest2InnerInit
> $1.apply(S.scala:1112)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.S$.net$liftweb$http$S$$_nest2InnerInit(S.scala:1111)
>         net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun
> $apply$28$$anonfun$apply$29$$anonfun$apply$30$$anonfun$apply$31.apply
> (S.scala:1133)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun
> $apply$28$$anonfun$apply$29$$anonfun$apply$30.apply(S.scala:1132)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun
> $apply$28$$anonfun$apply$29.apply(S.scala:1131)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1$$anonfun
> $apply$28.apply(S.scala:1130)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.S$$anonfun$net$liftweb$http$S$$_innerInit$1.apply
> (S.scala:1129)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.S$.net$liftweb$http$S$$_innerInit(S.scala:1128)
>         net.liftweb.http.S$$anonfun$_init$1$$anonfun$apply$38$$anonfun$apply
> $39$$anonfun$apply$40$$anonfun$apply$41$$anonfun$apply$42.apply
> (S.scala:1175)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.S$$anonfun$_init$1$$anonfun$apply$38$$anonfun$apply
> $39$$anonfun$apply$40$$anonfun$apply$41.apply(S.scala:1174)
>         net.liftweb.http.CoreRequestVarHandler$class.apply(Vars.scala:325)
>         net.liftweb.http.RequestVarHandler$.apply(Vars.scala:248)
>         net.liftweb.http.S$$anonfun$_init$1$$anonfun$apply$38$$anonfun$apply
> $39$$anonfun$apply$40.apply(S.scala:1173)
>         net.liftweb.http.CoreRequestVarHandler$class.apply(Vars.scala:325)
>         net.liftweb.http.TransientRequestVarHandler$.apply(Vars.scala:252)
>         net.liftweb.http.S$$anonfun$_init$1$$anonfun$apply$38$$anonfun$apply
> $39.apply(S.scala:1172)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.S$$anonfun$_init$1$$anonfun$apply$38.apply(S.scala:
> 1171)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.S$$anonfun$_init$1.apply(S.scala:1170)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.S$._init(S.scala:1169)
>         net.liftweb.http.S$.init(S.scala:825)
>         net.liftweb.http.LiftServlet.doService(LiftServlet.scala:170)
>         net.liftweb.http.LiftServlet$$anonfun$doIt$1$1.apply
> (LiftServlet.scala:72)
>         net.liftweb.http.LiftServlet$$anonfun$doIt$1$1.apply
> (LiftServlet.scala:72)
>         net.liftweb.util.TimeHelpers$class.calcTime(TimeHelpers.scala:242)
>         net.liftweb.util.Helpers$.calcTime(Helpers.scala:30)
>         net.liftweb.util.TimeHelpers$class.logTime(TimeHelpers.scala:251)
>         net.liftweb.util.Helpers$.logTime(Helpers.scala:30)
>         net.liftweb.http.LiftServlet.doIt$1(LiftServlet.scala:71)
>         net.liftweb.http.LiftServlet.service(LiftServlet.scala:76)
>         net.liftweb.http.provider.HTTPProvider$$anonfun$service$3.apply
> (HTTPProvider.scala:55)
>         net.liftweb.http.provider.HTTPProvider$$anonfun$service$3.apply
> (HTTPProvider.scala:55)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.URLRewriter$.doWith(Req.scala:518)
>         net.liftweb.http.provider.HTTPProvider$class.service
> (HTTPProvider.scala:54)
>         net.liftweb.http.LiftFilter.service(LiftServlet.scala:523)
>         net.liftweb.http.provider.servlet.ServletFilterProvider
> $class.protected$service(ServletFilterProvider.scala:43)
>         net.liftweb.http.LiftFilter.protected$service(LiftServlet.scala:523)
>         net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun
> $doFilter$1$$anonfun$apply$1.apply(ServletFilterProvider.scala:43)
>         net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun
> $doFilter$1$$anonfun$apply$1.apply(ServletFilterProvider.scala:38)
>         net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$9$$anonfun$apply
> $10$$anonfun$apply$11$$anonfun$apply$12.apply(Vars.scala:331)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$9$$anonfun$apply
> $10$$anonfun$apply$11.apply(Vars.scala:330)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$9$$anonfun$apply
> $10.apply(Vars.scala:329)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$9.apply
> (Vars.scala:328)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.CoreRequestVarHandler$class.apply(Vars.scala:327)
>         net.liftweb.http.RequestVarHandler$.apply(Vars.scala:248)
>         net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun
> $doFilter$1.apply(ServletFilterProvider.scala:37)
>         net.liftweb.http.provider.servlet.ServletFilterProvider$$anonfun
> $doFilter$1.apply(ServletFilterProvider.scala:37)
>         net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$9$$anonfun$apply
> $10$$anonfun$apply$11$$anonfun$apply$12.apply(Vars.scala:331)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$9$$anonfun$apply
> $10$$anonfun$apply$11.apply(Vars.scala:330)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$9$$anonfun$apply
> $10.apply(Vars.scala:329)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.CoreRequestVarHandler$$anonfun$apply$9.apply
> (Vars.scala:328)
>         net.liftweb.util.ThreadGlobal.doWith(ThreadGlobal.scala:67)
>         net.liftweb.http.CoreRequestVarHandler$class.apply(Vars.scala:327)
>         net.liftweb.http.TransientRequestVarHandler$.apply(Vars.scala:252)
>         net.liftweb.http.provider.servlet.ServletFilterProvider$class.doFilter
> (ServletFilterProvider.scala:36)
>         net.liftweb.http.LiftFilter.doFilter(LiftServlet.scala:523)
>         org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter
> (ServletHandler.java:1115)
>         org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
> 361)
>         org.mortbay.jetty.security.SecurityHandler.handle
> (SecurityHandler.java:216)
>         org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
> 181)
>         org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
> 766)
>         org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
>         org.mortbay.jetty.handler.ContextHandlerCollection.handle
> (ContextHandlerCollection.java:230)
>         org.mortbay.jetty.handler.HandlerCollection.handle
> (HandlerCollection.java:114)
>         org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
> 152)
>         org.mortbay.jetty.Server.handle(Server.java:324)
>         org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
> 535)
>         org.mortbay.jetty.HttpConnection$RequestHandler.content
> (HttpConnection.java:880)
>         org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:746)
>         org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
>         org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>         org.mortbay.io.nio.SelectChannelEndPoint.run
> (SelectChannelEndPoint.java:409)
>         org.mortbay.thread.QueuedThreadPool$PoolThread.run
> (QueuedThreadPool.java:522)
>
> I did move to the OnDiskFileParamHolder, but that doesn't make a
> difference I guess.
>
> The behavior I want of course is to issue some S.error(...) but go on
> displaying the template and preserving the other posted field
> contents.
>
> Thanks a lot,
>
> Tim

--

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