FileManagement package

Lots of work this past week on the FileManagement package.  Not yet finished, but getting close.  Note that JavaDoc comments are in need of tweaking and should not be trusted.
I wanted to inject some additional reasoning (text) into the exception.  So, I am re-throwing the SecurityException but with additional implementation-reasoning for why/where it happened.  This is occurring within the SwingWorker’s doInBackground method so it is going to get exposed by get() as an ExecutionException with the original execution available via ex.getCause().

 

- Jeff

 

From: Spencer Marks [mailto:notifications@github.com] 
Sent: Monday, June 23, 2014 7:25 AM
To: JeffBlodgett/FileSieve
Cc: Jeff Blodgett
Subject: Re: [FileSieve] FileManagement package (#5)

 

In src/main/java/FileSieve/BusinessLogic/FileManagement/ConcurrentFileManager.java:

> +                }
> +            } catch (SecurityException e) {
> +                throw new SecurityException("missing read access on source path (root, subfolder, or file) and/or write access on target path", e);
> +            } catch (IOException e) {
> +                throw new IOException("IOException while calculating bytes to copy", e);
> +            }
> +
> +            try {
> +                copyFiles(sourcePathname, targetPathname);
> +                allCopiesSuccessful = true;
> +            } catch (SecurityException e) {
> +                throw new SecurityException("SecurityException while reading or writing files/folders in the source or target root", e);
> +            } catch (IOException e) {
> +                throw new SecurityException("IOException while reading or writing files/folders in the source or target root", e);
> +            }
> +

java 7 allows you to handle multiple exceptions the same way with one catch clause. See http://docs.oracle.com/javase/7/docs/technotes/guides/language/catch-multiple.html

however, in this case, it looks like you don't need to catch SecurityException all at. Because you catch and then throw a new one immediately. 

—
Reply to this email directly or view it on GitHub <https://github.com/JeffBlodgett/FileSieve/pull/5/files#r14070428> .