Uploaded image for project: 'XMLGraphicsCommons'
  1. XMLGraphicsCommons
  2. XGC-25

Should never use Error to report runtime errors

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Resolution: Fixed
    • 1.3.1
    • None
    • image codecs
    • None
    • Operating System: Windows XP
      Platform: PC

    Description

      See BATIK-906:

      TIFFImageEncoder uses Error to report unexpected conditions, e.g.

      switch(dataType) {
      case DataBuffer.TYPE_BYTE:
      if(sampleSize[0] != 1 && sampleSize[0] == 4 &&
      sampleSize[0] != 8)

      { throw new Error("TIFFImageEncoder2"); }

      break;

      Using Error makes it hard to safely catch the exception, as there are some
      Errors that should not be caught (e.g. ThreadDeath)

      The code should use a more specific Error, e.g. RuntimeException or
      IllegalArgumentException or InvalidParameterException.

      There are a few other classes that use Error():

      TIFF*

      Glyphs
      AbstractGraphics2D
      TransformType

      Please can these be changed to use a RuntimeError of some kind?

      Attachments

        Activity

          People

            general@xmlgraphics.apache.org XML Graphics Project Mailing List
            sebb Sebb
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: