Bug 47174 - Should never use Error to report runtime errors
Summary: Should never use Error to report runtime errors
Status: RESOLVED FIXED
Alias: None
Product: XMLGraphicsCommons - Now in Jira
Classification: Unclassified
Component: image codecs (show other bugs)
Version: 1.3.1
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: --
Assignee: XML Graphics Project Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-09 03:41 UTC by Sebb
Modified: 2012-04-10 18:47 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebb 2009-05-09 03:41:51 UTC
See Bug 47171:

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?