[ 
https://issues.apache.org/jira/browse/GEOMETRY-138?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17387352#comment-17387352
 ] 

Gilles Sadowski commented on GEOMETRY-138:
------------------------------------------

{quote}
# Wrap {{IOException}} [in] {{UncheckedIOException}}.
{quote}

+1

bq. It sounds like you consider IAE as the best match for parsing and syntax 
errors [...]

Actually, I'd prefer 
[IllegalStateException|https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html]
 (if just to avoid some confusion where there is no immediately visible 
"argument").

Note that I'm not totally against having some {{GeometryParseException}} if you 
think that it would help in gathering a failure's context before formatting a 
complete error message... [Still TBD is whether it is necessary that it be part 
of the public API.  If there is use-case...]

{quote}
{code}
/**
 * ...
 * @throws RuntimeException if the input data is syntactically or 
mathematically invalid
 * @throws UncheckedIOException if an I/O error occurs
 */
BoundarySource3D read(...) { ... }
{code}
feels incorrect to me [...]
{quote}
To me too.

bq. adding more detail seems excessive, prone to error, and difficult to 
maintain.

Why?
Since we know which exceptions can be raised, we can document (all of) them.

A careful application developer would catch all advertised exceptions 
individually:
{code}
try {
    BoundarySource3D s = BoundarySource3D.read(input);
    // ...
} catch (IllegalStateException |
         UncheckedIOException  e) {
    LOG.error("Problem reading input {}", input);
    throw new AppException("ASF Commons Geometry failure", e);
}
{code}

bq. catching general exceptions like this is typically viewed as a code smell 
and something to avoid.

Indeed (cf. above).


> Use unchecked exceptions in IO modules
> --------------------------------------
>
>                 Key: GEOMETRY-138
>                 URL: https://issues.apache.org/jira/browse/GEOMETRY-138
>             Project: Apache Commons Geometry
>          Issue Type: Improvement
>            Reporter: Matt Juntunen
>            Priority: Major
>
> The IO modules should not throw checked exceptions, e.g. {{IOException}}. 
> Instead, a new unchecked {{GeometryIOException}} class should be created to 
> represent all IO and parsing failures.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to