258 if (archive == null) { |
258 if (archive == null) { |
259 try { |
259 try { |
260 archive = openArchive(directory); |
260 archive = openArchive(directory); |
261 } catch (IOException ex) { |
261 } catch (IOException ex) { |
262 log.error("error.reading.file", |
262 log.error("error.reading.file", |
263 directory, ex.getLocalizedMessage()); |
263 directory, getMessage(ex)); |
264 return; |
264 return; |
265 } |
265 } |
266 } |
266 } |
267 |
267 |
268 List<String> files = archive.getFiles(subdirectory); |
268 List<String> files = archive.getFiles(subdirectory); |
487 } |
487 } |
488 } catch (FileNotFoundException ex) { |
488 } catch (FileNotFoundException ex) { |
489 archive = new MissingArchive(zipFileName); |
489 archive = new MissingArchive(zipFileName); |
490 } catch (IOException ex) { |
490 } catch (IOException ex) { |
491 if (zipFileName.exists()) |
491 if (zipFileName.exists()) |
492 log.error("error.reading.file", zipFileName, ex.getLocalizedMessage()); |
492 log.error("error.reading.file", zipFileName, getMessage(ex)); |
493 archive = new MissingArchive(zipFileName); |
493 archive = new MissingArchive(zipFileName); |
494 } |
494 } |
495 |
495 |
496 archives.put(origZipFileName, archive); |
496 archives.put(origZipFileName, archive); |
497 } |
497 } |
836 if (isRelativeUri(result)) |
836 if (isRelativeUri(result)) |
837 return result; |
837 return result; |
838 } |
838 } |
839 throw new IllegalArgumentException("Invalid relative path: " + file); |
839 throw new IllegalArgumentException("Invalid relative path: " + file); |
840 } |
840 } |
|
841 |
|
842 /** |
|
843 * Get a detail message from an IOException. |
|
844 * Most, but not all, instances of IOException provide a non-null result |
|
845 * for getLocalizedMessage(). But some instances return null: in these |
|
846 * cases, fallover to getMessage(), and if even that is null, return the |
|
847 * name of the exception itself. |
|
848 * @param e an IOException |
|
849 * @return a string to include in a compiler diagnostic |
|
850 */ |
|
851 public static String getMessage(IOException e) { |
|
852 String s = e.getLocalizedMessage(); |
|
853 if (s != null) |
|
854 return s; |
|
855 s = e.getMessage(); |
|
856 if (s != null) |
|
857 return s; |
|
858 return e.toString(); |
|
859 } |
841 } |
860 } |