OK, I reworked it a bit so that you not only get the exception, but you get a stack trace. I can't think of any sane reason that you would want a snippet constructor exception so I figured the trace would be useful for troubleshooting. It's checked in on the wip-dcb-mighdoll-snippet-createexcpt branch. Any objections before I merge it?
Derek On Fri, Mar 6, 2009 at 10:47 AM, Derek Chen-Becker <[email protected]>wrote: > I agree that it's an iffy pattern, but I also think that it's important to > make error messages as clear as possible. I'm testing the patch right now > (made a minor mod) and I'll push the branch to github in a little bit for > review. > > Derek > > On Fri, Mar 6, 2009 at 9:14 AM, Timothy Perrett > <[email protected]>wrote: > >> >> Lee, >> >> That seems like a pretty dangerous opertation. Wouldn’t you do: >> >> class MySnippet { >> val file: Box[Source] = tryo { >> Source.fromFile("mistypedFileName") >> } >> } >> >> In this way you could then use pattern matching and avoid NPE’s >> >> Cheers, Tim >> - Show quoted text - >> >> >> On 06/03/2009 16:04, "Lee Mighdoll" <[email protected]> wrote: >> >> - Show quoted text - >> >> Sure, thanks for taking a look. My snippet class had something like this: >> >> import scala.io.Source >> >> class MySnippet { >> val file = Source.fromFile("mistypedFileName") >> } >> >> (The patched version generates two error log messages in this case. I >> couldn't figure out a small patch to make it just one message.) >> >> Lee >> >> On Fri, Mar 6, 2009 at 7:20 AM, Derek Chen-Becker <[email protected]> >> wrote: >> >> Let me create a branch for this and test it out. Also, could you tell me >> what the error was with your snippet so I can compare current behavior with >> what the patch provides? >> >> Derek >> >> >> On Thu, Mar 5, 2009 at 10:59 PM, Lee Mighdoll <[email protected]> >> wrote: >> >> When I had a bug which threw an exception instantiating my snippet, Lift >> logged a confusing error message: "ClassNotFound". The class was found, it >> just didn't run correctly... >> >> Enclosed is a patch to show a more informative error message. >> >> Lee >> >> >> >> >> >> >> >> >> >> >> >> >> > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
