From: Alan Chen Date: 2002-07-19T09:31:02+09:00 Subject: Re: Can you only catch errors one level deep? On Fri, Jul 19, 2002 at 09:04:02AM +0900, Philip Mak wrote: [previous writing dropped] > The problem with "rescue LoadError" is that it will also catch errors > it wasn't meant to! In my case, the file it loaded existed, but > requiring that file threw a LoadError because there was some other > problem with it. So the "rescue" caught an error it wasn't meant to > catch, and just made debugging harder. What errors did rescue LoadError catch? Where they derived from LoadError? > This seems to be an inflexibility with the begin/rescue/end construct. > If 'require' was a function that returned a false value upon failing > to load its argument, then the code could have done this: > > Any thoughts about this inflexibility of the begin/rescue/end system? I'm not sure it's really an inflexibility of the rescue system. I think you're just trying to assign more subtle semantics to the LoadError exception. I take LoadError to mean that there is an error preventing the the required code to operate correctly. Maybe the file doesn't exist, or there's a syntax error in the required code, or you need to load a dependency of the required file first. If you want better debugging, you could log the details of the LoadError, even if you have a specific action to recover. - alan -- Alan Chen Digikata LLC http://digikata.com