Changeset 3104


Ignore:
Timestamp:
08/27/07 10:03:05 (12 years ago)
Author:
curtis
Message:

A bunch of miscellaneous bugfixes and tweaks:

  • Remove some faulty OME-XML processing logic from DataConverter.
  • Remove a bunch of places where Exception was being caught.
  • Fix OMETiffReader and TCSReader to respect open flag.
  • Add flush method to LogTools.
  • Flesh out some Javadocs.
Location:
trunk/loci/formats
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/FormatReader.java

    r3083 r3104  
    411411  public void setNormalized(boolean normalize) { 
    412412    FormatTools.assertId(currentId, false, 1); 
    413     if (currentId != null) { 
    414       String s = "setNormalized called with open file."; 
    415       if (debug && debugLevel >= 2) trace(s); 
    416       else LogTools.println("Warning: " + s); 
    417     } 
    418413    normalizeData = normalize; 
    419414  } 
     
    427422  public void setMetadataCollected(boolean collect) { 
    428423    FormatTools.assertId(currentId, false, 1); 
    429     if (currentId != null) { 
    430       String s = "setMetadataCollected called with open file."; 
    431       if (debug && debugLevel >= 2) trace(s); 
    432       else LogTools.println("Warning: " + s); 
    433     } 
    434424    collectMetadata = collect; 
    435425  } 
     
    443433  public void setOriginalMetadataPopulated(boolean populate) { 
    444434    FormatTools.assertId(currentId, false, 1); 
    445     if (currentId != null) { 
    446       String s = "setOriginalMetadataPopulated called with open file."; 
    447       if (debug && debugLevel >= 2) trace(s); 
    448       else LogTools.println("Warning: " + s); 
    449     } 
    450435    saveOriginalMetadata = populate; 
    451436  } 
     
    500485  public void setMetadataFiltered(boolean filter) { 
    501486    FormatTools.assertId(currentId, false, 1); 
    502     if (currentId != null) { 
    503       String s = "setMetadataFiltered called with open file."; 
    504       if (debug && debugLevel >= 2) trace(s); 
    505       else LogTools.println("Warning: " + s); 
    506     } 
    507487    filterMetadata = filter; 
    508488  } 
     
    516496  public void setMetadataStore(MetadataStore store) { 
    517497    FormatTools.assertId(currentId, false, 1); 
    518     if (currentId != null) { 
    519       String s = "setMetadataStore called with open file."; 
    520       if (debug && debugLevel >= 2) trace(s); 
    521       else LogTools.println("Warning: " + s); 
    522     } 
    523498    metadataStore = store; 
    524499  } 
  • trunk/loci/formats/FormatTools.java

    r3097 r3104  
    420420 
    421421  /** 
    422    * Asserts that the current file is either null, nor not, according to the 
     422   * Asserts that the current file is either null, or not, according to the 
    423423   * given flag. If the assertion fails, an IllegalStateException is thrown. 
    424424   * @param currentId File name to test. 
     
    454454  // -- Utility methods -- metadata conversion -- 
    455455 
     456  /** 
     457   * Copies information from a metadata retrieval object 
     458   * (source) into a metadata store (destination). 
     459   */ 
    456460  public static void convertMetadata(MetadataRetrieve source, 
    457461    MetadataStore dest) 
  • trunk/loci/formats/ImageTools.java

    r3097 r3104  
    18921892 
    18931893    BufferedImage result = null; 
     1894    Image scaled = scaleAWT(source, width, height, Image.SCALE_AREA_AVERAGING); 
    18941895    try { 
    1895       result = makeBuffered(scaleAWT(source, width, height, 
    1896         Image.SCALE_AREA_AVERAGING), source.getColorModel()); 
     1896      result = makeBuffered(scaled, source.getColorModel()); 
    18971897    } 
    18981898    catch (Exception e) { 
    1899       result = makeBuffered(scaleAWT(source, width, height, 
    1900         Image.SCALE_AREA_AVERAGING)); 
     1899      // CTR TODO - eliminate catch-all exception handling 
     1900      result = makeBuffered(scaled); 
    19011901    } 
    19021902    return padImage(result, finalWidth, finalHeight); 
  • trunk/loci/formats/LegacyQTTools.java

    r3099 r3104  
    203203      return new Dimension(width, height); 
    204204    } 
    205     catch (Exception e) { 
     205    catch (ReflectException e) { 
    206206      r.exec("QTSession.close()"); 
    207207      throw new FormatException("PICT height determination failed", e); 
     
    257257        width, height, colorModel, pixels, 0, intsPerRow)); 
    258258    } 
    259     catch (Exception e) { 
     259    catch (ReflectException e) { 
    260260      try { r.exec("QTSession.close()"); } 
    261261      catch (ReflectException exc) { LogTools.trace(exc); } 
  • trunk/loci/formats/Log.java

    r3015 r3104  
    4949  } 
    5050 
     51  /** Flushes buffer to the log. Override to control how logging occurs. */ 
     52  public void flush() { 
     53    // default implementation flushes the console 
     54    System.out.flush(); 
     55  } 
     56 
    5157  public void print(boolean x) { print("" + x); } 
    5258  public void print(char x) { print("" + x); } 
  • trunk/loci/formats/LogTools.java

    r3015 r3104  
    6868  public static void trace(Throwable t) { log.trace(t); } 
    6969 
     70  public static void flush()  { log.flush(); } 
     71 
    7072} 
  • trunk/loci/formats/ReflectedUniverse.java

    r3051 r3104  
    156156    } 
    157157 
    158     Object result; 
     158    Object result = null; 
    159159 
    160160    // parse parentheses 
     
    230230 
    231231      // invoke constructor 
    232       try { 
    233         result = constructor.newInstance(args); 
    234       } 
    235       catch (Exception exc) { 
     232      Exception exc = null; 
     233      try { result = constructor.newInstance(args); } 
     234      catch (InstantiationException e) { exc = e; } 
     235      catch (IllegalAccessException e) { exc = e; } 
     236      catch (InvocationTargetException e) { exc = e; } 
     237      if (exc != null) { 
    236238        if (debug) LogTools.trace(exc); 
    237239        throw new ReflectException("Cannot instantiate object", exc); 
     
    281283 
    282284      // invoke method 
    283       try { 
    284         result = method.invoke(var, args); 
    285       } 
    286       catch (Exception exc) { 
    287         if (debug) LogTools.trace(exc); 
    288         throw new ReflectException("Cannot execute method: " + 
    289           methodName, exc); 
     285      Exception exc = null; 
     286      try { result = method.invoke(var, args); } 
     287      catch (IllegalAccessException e) { exc = e; } 
     288      catch (InvocationTargetException e) { exc = e; } 
     289      if (exc != null) { 
     290        if (debug) LogTools.trace(exc); 
     291        throw new ReflectException("Cannot execute method: " + methodName, exc); 
    290292      } 
    291293    } 
     
    400402      } 
    401403      Object fieldVal; 
    402       try { 
    403         fieldVal = field.get(var); 
    404       } 
    405       catch (Exception exc) { 
     404      try { fieldVal = field.get(var); } 
     405      catch (IllegalAccessException exc) { 
    406406        if (debug) LogTools.trace(exc); 
    407407        throw new ReflectException("Cannot get field value: " + varName, exc); 
  • trunk/loci/formats/TiffTools.java

    r3097 r3104  
    589589        if (fields[i].getInt(null) == value) return fields[i].getName(); 
    590590      } 
    591       catch (Exception exc) { } 
     591      catch (IllegalAccessException exc) { } 
    592592    } 
    593593    return "" + value; 
     
    12991299        } 
    13001300        catch (Exception e) { 
     1301          // CTR TODO - eliminate catch-all exception handling 
    13011302          if (strip == 0) { 
    13021303            if (e instanceof FormatException) throw (FormatException) e; 
  • trunk/loci/formats/codec/AdobeDeflateCodec.java

    r3015 r3104  
    2525package loci.formats.codec; 
    2626 
     27import java.io.IOException; 
    2728import java.io.PipedInputStream; 
    2829import java.util.zip.Inflater; 
     
    8586      return bytes.toByteArray(); 
    8687    } 
    87     catch (Exception e) { 
     88    catch (IOException e) { 
    8889      throw new FormatException("Error uncompressing " + 
    8990        "Adobe Deflate (ZLIB) compressed image strip.", e); 
  • trunk/loci/formats/gui/DataConverter.java

    r3015 r3104  
    3131import java.awt.image.*; 
    3232import java.io.*; 
    33 import java.util.Vector; 
     33//import java.util.Vector; 
    3434import javax.swing.*; 
    3535import javax.swing.border.EmptyBorder; 
     
    3737import loci.formats.*; 
    3838import loci.formats.ome.OMEXMLMetadataStore; 
    39 import loci.formats.out.TiffWriter; 
    40 import org.openmicroscopy.xml.*; 
    41 import org.openmicroscopy.xml.st.*; 
     39//import loci.formats.out.TiffWriter; 
     40//import org.openmicroscopy.xml.*; 
     41//import org.openmicroscopy.xml.st.*; 
    4242 
    4343/** 
     
    323323        } 
    324324      } 
    325       catch (Exception exc) { LogTools.trace(exc); } 
     325      catch (FormatException exc) { LogTools.trace(exc); } 
     326      catch (IOException exc) { LogTools.trace(exc); } 
    326327 
    327328      updateLabels(pattern); 
     
    348349        } 
    349350      } 
    350       catch (Exception exc) { LogTools.trace(exc); } 
     351      catch (FormatException exc) { LogTools.trace(exc); } 
     352      catch (IOException exc) { LogTools.trace(exc); } 
    351353    } 
    352354    else if ("zChoice".equals(cmd)) { 
     
    387389  public void stateChanged(ChangeEvent e) { 
    388390    if (e.getSource() == series) { 
    389       try { 
    390         swap.setSeries(((Integer) series.getValue()).intValue() - 1); 
    391         updateLabels(input.getText()); 
    392       } 
    393       catch (Exception exc) { LogTools.trace(exc); } 
     391      swap.setSeries(((Integer) series.getValue()).intValue() - 1); 
     392      updateLabels(input.getText()); 
    394393    } 
    395394  } 
     
    623622 
    624623            // if we're writing a TIFF file, insert an OME-XML block 
    625             if (writer.getWriter(outFile) instanceof TiffWriter) { 
    626               RandomAccessFile raf = new RandomAccessFile(outFile, "rw"); 
    627  
    628               OMENode root = (OMENode) 
    629                 ((OMEXMLMetadataStore) swap.getMetadataStore()).getRoot(); 
    630  
    631               // add TiffData element here 
    632               Vector images = root.getChildNodes("Image"); 
    633               for (int p=0; p<images.size(); p++) { 
    634                 PixelsNode pix = 
    635                   (PixelsNode) ((ImageNode) images.get(p)).getDefaultPixels(); 
    636                 DOMUtil.createChild(pix.getDOMElement(), "TiffData"); 
    637               } 
    638  
    639               TiffTools.overwriteIFDValue(raf, 0, TiffTools.IMAGE_DESCRIPTION, 
    640                 root.writeOME(true)); 
    641               raf.close(); 
    642             } 
     624            // CTR TODO fix this code; it is wrong 
     625            // First of all, it writes OMECA-XML instead of OME-XML. 
     626            // Secondly, this logic should not be in the DataConverter itself; 
     627            // DataConverter should just use OMETiffWriter, which handles it. 
     628//            if (writer.getWriter(outFile) instanceof TiffWriter) { 
     629//              RandomAccessFile raf = new RandomAccessFile(outFile, "rw"); 
     630// 
     631//              OMENode root = (OMENode) 
     632//                ((OMEXMLMetadataStore) swap.getMetadataStore()).getRoot(); 
     633// 
     634//              // add TiffData element here 
     635//              Vector images = root.getChildNodes("Image"); 
     636//              for (int p=0; p<images.size(); p++) { 
     637//                PixelsNode pix = 
     638//                  (PixelsNode) ((ImageNode) images.get(p)).getDefaultPixels(); 
     639//                DOMUtil.createChild(pix.getDOMElement(), "TiffData"); 
     640//              } 
     641// 
     642//              TiffTools.overwriteIFDValue(raf, 0, TiffTools.IMAGE_DESCRIPTION, 
     643//                root.writeOME(true)); 
     644//              raf.close(); 
     645//            } 
    643646          } 
    644647        } 
     
    656659      if (swap != null) swap.close(); 
    657660    } 
    658     catch (Exception exc) { 
     661    catch (FormatException exc) { 
     662      LogTools.trace(exc); 
     663      String err = exc.getMessage(); 
     664      if (err == null) err = exc.getClass().getName(); 
     665      msg("Sorry, an error occurred: " + err); 
     666      progress.setString(""); 
     667      progress.setValue(0); 
     668    } 
     669    catch (IOException exc) { 
    659670      LogTools.trace(exc); 
    660671      String err = exc.getMessage(); 
     
    714725      includeC.setEnabled(true); 
    715726    } 
    716     catch (Exception exc) { LogTools.trace(exc); } 
     727    catch (FormatException exc) { LogTools.trace(exc); } 
     728    catch (IOException exc) { LogTools.trace(exc); } 
    717729  } 
    718730 
  • trunk/loci/formats/gui/ImageViewer.java

    r3015 r3104  
    2929import java.awt.image.*; 
    3030import java.io.File; 
     31import java.io.IOException; 
    3132import javax.swing.*; 
    3233import javax.swing.border.BevelBorder; 
     
    225226      myReader.close(true); 
    226227    } 
    227     catch (Exception exc) { 
     228    catch (FormatException exc) { 
     229      LogTools.trace(exc); 
     230      wait(false); 
     231      return; 
     232    } 
     233    catch (IOException exc) { 
    228234      LogTools.trace(exc); 
    229235      wait(false); 
     
    258264      } 
    259265    } 
    260     catch (Exception exc) { LogTools.trace(exc); } 
     266    catch (FormatException exc) { LogTools.trace(exc); } 
     267    catch (IOException exc) { LogTools.trace(exc); } 
    261268    wait(false); 
    262269  } 
     
    268275    images = img; 
    269276 
    270     try { 
    271       sizeZ = reader.getSizeZ(); 
    272       sizeT = reader.getSizeT(); 
    273       sizeC = reader.getEffectiveSizeC(); 
    274       //if (reader.isRGB(id)) sizeC = (sizeC + 2) / 3; // adjust for RGB 
    275     } 
    276     catch (Exception exc) { LogTools.trace(exc); } 
     277    sizeZ = reader.getSizeZ(); 
     278    sizeT = reader.getSizeT(); 
     279    sizeC = reader.getEffectiveSizeC(); 
     280    //if (reader.isRGB(id)) sizeC = (sizeC + 2) / 3; // adjust for RGB 
    277281 
    278282    fileSave.setEnabled(true); 
     
    405409      int ndx = getImageIndex(); 
    406410      int[] zct = {-1, -1, -1}; 
    407       try { zct = in.getZCTCoords(ndx); } 
    408       catch (Exception exc) { LogTools.trace(exc); } 
     411      zct = in.getZCTCoords(ndx); 
    409412      if (zct[0] >= 0) { 
    410413        zSlider.removeChangeListener(this); 
     
    425428    else { 
    426429      // update N slider 
    427       int ndx = -1; 
    428       try { ndx = in.getIndex(getZ(), getC(), getT()); } 
    429       catch (Exception exc) { LogTools.trace(exc); } 
     430      int ndx = in.getIndex(getZ(), getC(), getT()); 
    430431      if (ndx >= 0) { 
    431432        nSlider.removeChangeListener(this); 
  • trunk/loci/formats/in/BaseTiffReader.java

    r3097 r3104  
    590590        creationDate = sdf.format(date); 
    591591      } 
    592       catch (Exception e) { 
    593         // TODO: eliminate catch-all exception handling 
     592      catch (NullPointerException e) { 
    594593        try { 
    595594          SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); 
     
    599598          creationDate = sdf.format(date); 
    600599        } 
    601         catch (Exception exc) { 
    602           // TODO: eliminate catch-all exception handling 
     600        catch (NullPointerException exc) { 
    603601          if (debug) trace(exc); 
    604602          creationDate = null; 
  • trunk/loci/formats/in/EPSReader.java

    r3097 r3104  
    227227            bps = Integer.parseInt(t.nextToken()); 
    228228          } 
    229           catch (Exception exc) { 
    230             // CTR TODO - eliminate catch-all exception handling 
     229          catch (NumberFormatException exc) { 
    231230            if (debug) trace(exc); 
    232231            core.sizeC[0] = Integer.parseInt(t.nextToken()); 
  • trunk/loci/formats/in/NikonReader.java

    r3015 r3104  
    264264      offset = TiffTools.getIFDIntValue(ifds[0], 330, false, 0); 
    265265    } 
    266     catch (Exception exc) { 
    267       // CTR TODO - eliminate catch-all exception handling 
     266    catch (FormatException exc) { 
    268267      if (debug) trace(exc); 
    269268      long[] array = TiffTools.getIFDLongArray(ifds[0], 330, false); 
  • trunk/loci/formats/in/OMETiffReader.java

    r3102 r3104  
    3333 
    3434/** 
    35  * OMETiffReader is the file format reader for OME-TIFF files. 
    36  * See http://www.loci.wisc.edu/ome/ome-tiff-spec.html 
     35 * OMETiffReader is the file format reader for 
     36 * <a href="http://www.loci.wisc.edu/ome/ome-tiff-spec.html">OME-TIFF</a> 
     37 * files. 
    3738 * 
    3839 * <dl><dt><b>Source code:</b></dt> 
     
    5253  /* @see loci.formats.IFormatHandler#isThisType(String, boolean) */ 
    5354  public boolean isThisType(String name, boolean open) { 
    54     if (!name.toLowerCase().endsWith("tif") && 
    55       !name.toLowerCase().endsWith("tiff")) 
    56     { 
    57       return false; 
    58     } 
     55    if (!super.isThisType(name, open)) return false; // check extension 
     56 
     57    // just checking the filename isn't enough to differentiate between 
     58    // OME-TIFF and regular TIFF; open the file and check more thoroughly 
     59    if (!open) return true; 
    5960 
    6061    try { 
     
    6970      return comment.indexOf("ome.xsd") >= 0; 
    7071    } 
    71     catch (Exception e) { return false; } 
     72    catch (IOException e) { return false; } 
    7273  } 
    7374 
  • trunk/loci/formats/in/OMEXMLReader.java

    r3097 r3104  
    441441      } 
    442442      else { 
    443         FormatTools.convertMetadata((MetadataRetrieve) r.getVar("omexml"), store); 
     443        FormatTools.convertMetadata((MetadataRetrieve) 
     444          r.getVar("omexml"), store); 
    444445      } 
    445446    } 
  • trunk/loci/formats/in/OpenlabReader.java

    r3097 r3104  
    140140 
    141141      // open image using pict reader 
     142      Exception exception = null; 
    142143      try { 
    143144        b = new byte[(int) (nextTag - in.getFilePointer())]; 
     
    150151        } 
    151152      } 
    152       catch (Exception exc) { 
    153         // CTR TODO - eliminate catch-all exception handling 
    154         if (debug) trace(exc); 
     153      catch (FormatException exc) { exception = exc; } 
     154      catch (IOException exc) { exception = exc; } 
     155      if (exception != null) { 
     156        if (debug) trace(exception); 
    155157 
    156158        b = null; 
  • trunk/loci/formats/in/QTReader.java

    r3060 r3104  
    300300    status("Parsing tags"); 
    301301 
    302     try { 
    303       parse(0, 0, in.length()); 
    304     } 
    305     catch (Exception exc) { 
     302    Exception exc = null; 
     303    try { parse(0, 0, in.length()); } 
     304    catch (FormatException e) { exc = e; } 
     305    catch (IOException e) { exc = e; } 
     306    if (exc != null) { 
    306307      if (debug) trace(exc); 
    307308      useLegacy = true; 
  • trunk/loci/formats/in/TCSReader.java

    r3046 r3104  
    4949  /* @see loci.formats.IFormatHandler#isThisType(String, boolean) */ 
    5050  public boolean isThisType(String name, boolean open) { 
    51     if (!name.toLowerCase().endsWith("tif") && 
    52       !name.toLowerCase().endsWith("tiff")) 
    53     { 
    54       return false; 
    55     } 
     51    if (!super.isThisType(name, open)) return false; // check extension 
     52 
     53    // just checking the filename isn't enough to differentiate between 
     54    // Leica TCS and regular TIFF; open the file and check more thoroughly 
     55    if (!open) return true; 
    5656 
    5757    try { 
     
    6565      return document.startsWith("CHANNEL"); 
    6666    } 
    67     catch (Exception e) { return false; } 
     67    catch (IOException e) { return false; } 
    6868  } 
    6969 
  • trunk/loci/formats/in/ZeissZVIReader.java

    r3097 r3104  
    449449 
    450450      try { blackValue = new Double(black); } 
    451       catch (Exception e) { } 
     451      catch (NumberFormatException e) { } 
    452452      try { whiteValue = new Double(white); } 
    453       catch (Exception e) { } 
     453      catch (NumberFormatException e) { } 
    454454      try { gammaValue = new Float(gamma); } 
    455       catch (Exception e) { } 
     455      catch (NumberFormatException e) { } 
    456456 
    457457      store.setDisplayChannel(new Integer(i), blackValue, whiteValue, 
     
    464464      Float exp = new Float(0.0); 
    465465      try { exp = new Float(exposure); } 
    466       catch (Exception e) { } 
     466      catch (NumberFormatException e) { } 
    467467 
    468468      store.setPlaneInfo(zct[0], zct[1], zct[2], null, exp, null); 
  • trunk/loci/formats/ome/OMEReader.java

    r3097 r3104  
    136136    c.addWantedFields("default_pixels", fs); 
    137137 
    138     try { 
    139       rs = DataServer.getDefaultServices(server); 
    140     } 
    141     catch (Exception e) { throw new FormatException(e); } 
     138    rs = DataServer.getDefaultServices(server); 
    142139 
    143140    rc = rs.getRemoteCaller(); 
  • trunk/loci/formats/ome/OMEWriter.java

    r3015 r3104  
    2626 
    2727import java.io.*; 
     28import java.net.MalformedURLException; 
    2829import loci.formats.*; 
    29  
    3030import org.openmicroscopy.ds.*; 
    3131import org.openmicroscopy.ds.dto.*; 
     
    158158        r.setImageServerURL(omeis); 
    159159      } 
    160       catch (Exception e) { 
     160      catch (ImageServerException e) { 
    161161        throw new FormatException("Could not find repository.", e); 
    162162      } 
     
    345345      validLogin = true; 
    346346    } 
    347     catch (Exception e) { 
     347    catch (MalformedURLException e) { 
    348348      validLogin = false; 
    349349      throw new FormatException("Login failed", e); 
  • trunk/loci/formats/ome/OMEXMLMetadataStore.java

    r3097 r3104  
    2727import java.io.IOException; 
    2828import java.lang.reflect.Constructor; 
     29import java.lang.reflect.InvocationTargetException; 
    2930import java.util.*; 
    3031import javax.xml.parsers.ParserConfigurationException; 
     
    17881789      return (OMEXMLNode) con.newInstance(new Object[] {base}); 
    17891790    } 
    1790     catch (Exception exc) { LogTools.trace(exc); } 
     1791    catch (ClassNotFoundException exc) { LogTools.trace(exc); } 
     1792    catch (NoSuchMethodException exc) { LogTools.trace(exc); } 
     1793    catch (InstantiationException exc) { LogTools.trace(exc); } 
     1794    catch (IllegalAccessException exc) { LogTools.trace(exc); } 
     1795    catch (InvocationTargetException exc) { LogTools.trace(exc); } 
    17911796    return null; 
    17921797  } 
  • trunk/loci/formats/ome/OmeisImporter.java

    r3097 r3104  
    604604    } 
    605605    catch (Exception exc) { 
     606      // NB: We really do want to catch all exception types here, 
     607      // to redirect output properly for the OME server. 
    606608      if (http) { 
    607609        importer.printHttpErrorHeader(); 
  • trunk/loci/formats/ome/package.html

    r2327 r3104  
    22Package containing Bio-Formats OME-related logic for 
    33OME-XML metadata, and database import, upload and download. 
     4Classes in this package require the OME Java package for 
     5working with OME-XML and/or the OME Perl database. 
    46</body></html> 
  • trunk/loci/formats/out/LegacyQTWriter.java

    r3101 r3104  
    179179        r.exec("imgDesc = seq.getDescription()"); 
    180180      } 
    181       catch (Exception e) { 
     181      catch (ReflectException e) { 
    182182        trace(e); 
    183183        throw new FormatException("Legacy QuickTime writer failed", e); 
     
    254254        "rate, imgDesc, one, sync)"); 
    255255    } 
    256     catch (Exception e) { 
     256    catch (ReflectException e) { 
    257257      trace(e); 
    258258      throw new FormatException("Legacy QuickTime writer failed", e); 
     
    270270        r.exec("QTSession.close()"); 
    271271      } 
    272       catch (Exception e) { 
     272      catch (ReflectException e) { 
    273273        trace(e); 
    274274        throw new FormatException("Legacy QuickTime writer failed", e); 
  • trunk/loci/formats/test/ReaderTest.java

    r3015 r3104  
    2828import java.io.*; 
    2929import java.security.MessageDigest; 
     30import java.security.NoSuchAlgorithmException; 
    3031import java.util.*; 
    3132import loci.formats.*; 
     
    116117      assert success; 
    117118    } 
    118     catch (Exception exc) { 
     119    catch (FormatException exc) { 
     120      writeLog(file + " failed BufferedImage test"); 
     121      writeLog(exc); 
     122      assert false; 
     123    } 
     124    catch (IOException exc) { 
    119125      writeLog(file + " failed BufferedImage test"); 
    120126      writeLog(exc); 
     
    152158      assert success; 
    153159    } 
    154     catch (Exception exc) { 
     160    catch (FormatException exc) { 
     161      writeLog(file + " failed byte array test"); 
     162      writeLog(exc); 
     163      assert false; 
     164    } 
     165    catch (IOException exc) { 
    155166      writeLog(file + " failed byte array test"); 
    156167      writeLog(exc); 
     
    193204      assert success; 
    194205    } 
    195     catch (Exception exc) { 
     206    catch (FormatException exc) { 
     207      writeLog(file + " failed thumbnail BufferedImage test"); 
     208      writeLog(exc); 
     209      assert false; 
     210    } 
     211    catch (IOException exc) { 
    196212      writeLog(file + " failed thumbnail BufferedImage test"); 
    197213      writeLog(exc); 
     
    229245      assert success; 
    230246    } 
    231     catch (Exception exc) { 
     247    catch (FormatException exc) { 
    232248      writeLog(file + " failed thumbnail byte array test"); 
    233249      writeLog(exc); 
    234250      assert false; 
    235251    } 
    236   } 
    237  
    238   /** 
    239    * @testng.test dataProvider = "provider" 
    240     *             groups = "all fast" 
     252    catch (IOException exc) { 
     253      writeLog(file + " failed thumbnail byte array test"); 
     254      writeLog(exc); 
     255      assert false; 
     256    } 
     257  } 
     258 
     259  /** 
     260   * @testng.test dataProvider = "provider" 
     261   *              groups = "all fast" 
    241262   */ 
    242263  public void testImageCount(String file) { 
     
    260281      assert success; 
    261282    } 
    262     catch (Exception exc) { 
     283    catch (FormatException exc) { 
     284      writeLog(file + " failed image count test"); 
     285      writeLog(exc); 
     286      assert false; 
     287    } 
     288    catch (IOException exc) { 
    263289      writeLog(file + " failed image count test"); 
    264290      writeLog(exc); 
     
    309335      assert success; 
    310336    } 
    311     catch (Exception exc) { 
     337    catch (FormatException exc) { 
     338      writeLog(file + " failed OME-XML sanity test"); 
     339      writeLog(exc); 
     340      assert false; 
     341    } 
     342    catch (IOException exc) { 
    312343      writeLog(file + " failed OME-XML sanity test"); 
    313344      writeLog(exc); 
     
    364395      assert true; 
    365396    } 
    366     catch (Exception exc) { 
     397    catch (FormatException exc) { 
     398      writeLog(file + " failed consistent metadata test"); 
     399      writeLog(exc); 
     400      assert false; 
     401    } 
     402    catch (IOException exc) { 
    367403      writeLog(file + " failed consistent metadata test"); 
    368404      writeLog(exc); 
     
    411447      assert success; 
    412448    } 
    413     catch (Exception e) { 
     449    catch (FormatException e) { 
     450      writeLog(file + " failed memory test"); 
     451      writeLog(e); 
     452      assert false; 
     453    } 
     454    catch (IOException e) { 
    414455      writeLog(file + " failed memory test"); 
    415456      writeLog(e); 
     
    446487      assert true; 
    447488    } 
    448     catch (Exception e) { 
     489    catch (FormatException e) { 
     490      writeLog(file + " failed consistent access time test"); 
     491      writeLog(e); 
     492      assert false; 
     493    } 
     494    catch (IOException e) { 
    449495      writeLog(file + " failed consistent access time test"); 
    450496      writeLog(e); 
     
    480526      assert true; 
    481527    } 
    482     catch (Exception e) { 
     528    catch (FormatException e) { 
     529      writeLog(file + " failed sane used files test"); 
     530      writeLog(e); 
     531      assert false; 
     532    } 
     533    catch (IOException e) { 
    483534      writeLog(file + " failed sane used files test"); 
    484535      writeLog(e); 
     
    504555      assert xml != null; 
    505556    } 
    506     catch (Exception e) { 
     557    catch (FormatException e) { 
     558      writeLog(file + " failed OME-XML validation"); 
     559      writeLog(e); 
     560      assert false; 
     561    } 
     562    catch (IOException e) { 
    507563      writeLog(file + " failed OME-XML validation"); 
    508564      writeLog(e); 
     
    535591      } 
    536592    } 
    537     catch (Exception exc) { 
     593    catch (FormatException exc) { 
    538594      writeLog(file + " failed pixels consistency"); 
    539595      writeLog(exc); 
    540596      assert false; 
    541597    } 
     598    catch (IOException exc) { 
     599      writeLog(file + " failed pixels consistency"); 
     600      writeLog(exc); 
     601      assert false; 
     602    } 
    542603    assert success; 
    543604  } 
     
    548609   */ 
    549610  public void writeConfigFiles(String file) { 
     611    Exception exc = null; 
    550612    try { 
    551613      FileStitcher reader = new FileStitcher(); 
     
    596658      assert true; 
    597659    } 
    598     catch (Exception e) { 
     660    catch (FormatException e) { exc = e; } 
     661    catch (IOException e) { exc = e; } 
     662    if (exc != null) { 
    599663      try { 
    600664        File f = new File(new Location(file).getParent(), ".bioformats"); 
     
    604668        assert true; 
    605669      } 
    606       catch (IOException exc) { } 
     670      catch (IOException e) { } 
    607671    } 
    608672  } 
     
    625689      return sb.toString(); 
    626690    } 
    627     catch (Exception e) { 
    628       writeLog(e); 
    629     } 
     691    catch (NoSuchAlgorithmException e) { writeLog(e); } 
    630692    return null; 
    631693  } 
     
    635697    if (logFile == null) createLogFile(); 
    636698    LogTools.println(s); 
    637     try { logFile.flush(); } 
    638     catch (IOException exc) { } 
     699    LogTools.flush(); 
    639700  } 
    640701 
     
    643704    if (logFile == null) createLogFile(); 
    644705    LogTools.trace(e); 
    645     try { logFile.flush(); } 
    646     catch (IOException exc) { } 
     706    LogTools.flush(); 
    647707  } 
    648708 
     
    652712      String date = new Date().toString().replaceAll(":", "-"); 
    653713      logFile = new FileWriter("bio-formats-test-" + date + ".log"); 
    654       logFile.flush(); 
    655714      TestLogger log = new TestLogger(logFile); 
    656715      LogTools.setLog(log); 
    657716    } 
    658     catch (IOException e) { 
    659  
    660     } 
     717    catch (IOException e) { } 
    661718  } 
    662719 
     
    746803      catch (IOException exc) { } 
    747804    } 
     805 
     806    public void flush() { 
     807      try { writer.flush(); } 
     808      catch (IOException exc) { } 
     809    } 
    748810  } 
    749811 
Note: See TracChangeset for help on using the changeset viewer.