You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by bu...@apache.org on 2009/05/09 00:57:11 UTC

DO NOT REPLY [Bug 47171] New: Should never use Error to report runtime errors

https://issues.apache.org/bugzilla/show_bug.cgi?id=47171

           Summary: Should never use Error to report runtime errors
           Product: Batik
           Version: 1.7
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: GVT
        AssignedTo: batik-dev@xmlgraphics.apache.org
        ReportedBy: sebb@apache.org


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 over 70 classes where Error is thrown - please can these be changed
to something more appropriate?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


DO NOT REPLY [Bug 47171] Should never use Error to report runtime errors

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47171





--- Comment #2 from Sebb <se...@apache.org>  2009-05-09 03:09:30 PST ---
Thanks, did not know about that project.
I've just had a look at the XML Graphics Commons version and that also uses
Error with rather cryptic messages, so that part has obviously not been
addressed.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


DO NOT REPLY [Bug 47171] Should never use Error to report runtime errors

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47171





--- Comment #1 from Helder Magalhães <he...@gmail.com>  2009-05-09 00:19:46 PST ---
(In reply to comment #0)
> TIFFImageEncoder uses Error to report unexpected conditions, e.g.

Although not very familiar with this, regarding this specific class I'd say
there's pending effort into using XML Graphics Commons [1] for the task (this
implementation should be abandoned in favor of a more compatible one (see bug
38183 and bug 46513).


> Using Error makes it hard to safely catch the exception, as there are some
> Errors that should not be caught (e.g. ThreadDeath)
[...]
> There are over 70 classes where Error is thrown [...]

I haven't dig up on this enough but, for what it's worth, I'd vote on this
also. :-)


[1] http://xmlgraphics.apache.org/commons/#features

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org