Point taken. Will avoid genetic catches going forward.
 On Sep 14, 2013 8:33 AM, "Josh Albrecht" <notifications@github.com> wrote:

> In src/main/scala/com/codexica/s3crate/filetree/local/LinuxFileTree.scala:
>
> > +    //get Path from File
> > +    val path = getPath(file)
> > +    try {
> > +      //check for SymLink
> > +      if (Files.isSymbolicLink(path)) SymLinkType()
> > +      //check for directory
> > +      else if (Files.isDirectory(path)) FolderType()
> > +      //check for file (we can probably skip this check and return FileType, as no other
> > +      //option currently exists. This is a precaution against the unknown
> > +      else if (Files.isRegularFile(path)) FileType()
> > +      //if not check succeeded - throw our generic InaccessibleDataError
> > +      else throw new InaccessibleDataError("wierd error. path is not a file, a directory or a symlink", null)
> > +    }
> > +    catch {
> > +      //and of course, if an exception was thrown somewhere, wrap it in InaccessibleDataError and re-throw
> > +      case ex => throw new InaccessibleDataError("exception trying to find file type", ex)
>
> This is super duper dangerous (matching all Throwables)--bad things
> include:
>
>    - Matching OutOfMemoryError
>    - Matching InterruptedException
>    - Matching flow control exceptions from Akka ...among MANY others.
>
> It's acceptable to match all Throwables in exactly one place--a top-level
> error handler/reporter. Anywhere else, in the worst case, you want to use
> this instead:
>
> } catch {
>     case NonFatal(t) => //do something with the non-fatal exception
> }
>
> In this case though, what things specifically do the Files.is*() functions
> throw? If they don't specify, I like to leave it empty and let them
> propagate. Then whenever errors are actually observed during testing or
> runtime, I go back and add the specific handler at the appropriate layer
> doing the appropriate wrapping. In this way I'll be able to differentiate
> between "file missing" and "invalid permissions", etc, which makes
> responding to the errors easier at whatever layer handles these errors.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/joshalbrecht/s3crate/pull/1/files#r6364036>
> .
>