Issue #533 Do not hide file resource exception

Add exception as suppressed
This commit is contained in:
Greg Wilkins 2016-04-23 09:33:17 +10:00
parent 132cd097ce
commit ec8e1055e3
1 changed files with 5 additions and 4 deletions

View File

@ -155,6 +155,7 @@ public abstract class Resource implements ResourceFactory, Closeable
* @param useCaches controls URLConnection caching * @param useCaches controls URLConnection caching
* @return A Resource object. * @return A Resource object.
* @throws MalformedURLException Problem accessing URI * @throws MalformedURLException Problem accessing URI
* @throws IOException Problem handling resource as file.
*/ */
public static Resource newResource(String resource, boolean useCaches) public static Resource newResource(String resource, boolean useCaches)
throws MalformedURLException throws MalformedURLException
@ -176,13 +177,13 @@ public abstract class Resource implements ResourceFactory, Closeable
// It's a file. // It's a file.
if (resource.startsWith("./")) if (resource.startsWith("./"))
resource=resource.substring(2); resource=resource.substring(2);
File file=new File(resource).getCanonicalFile(); File file=new File(resource).getCanonicalFile();
return new PathResource(file.toPath()); return new PathResource(file);
} }
catch(Exception e2) catch(IOException e2)
{ {
LOG.debug(Log.EXCEPTION,e2); // TODO throw the IOException instead
e.addSuppressed(e2);
throw e; throw e;
} }
} }