You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@forrest.apache.org by "Tim Williams (JIRA)" <ji...@apache.org> on 2006/08/04 14:07:14 UTC
[jira] Commented: (FOR-914) [Java Coding] Do not raise exception
when you can prevent them
[ http://issues.apache.org/jira/browse/FOR-914?page=comments#action_12425730 ]
Tim Williams commented on FOR-914:
----------------------------------
+1, though I'm probably as guilty as the next person;(
Some reference material:
http://www.javaworld.com/jw-08-2000/jw-0818-exceptions.html
> [Java Coding] Do not raise exception when you can prevent them
> --------------------------------------------------------------
>
> Key: FOR-914
> URL: http://issues.apache.org/jira/browse/FOR-914
> Project: Forrest
> Issue Type: Improvement
> Components: Core operations
> Affects Versions: 0.8-dev
> Reporter: Thorsten Scherler
>
> I do not like that an exception is not prevented but catched. There are tons of try catch blocks that are not needed at all if we use a
> cleaner solution.
> IMO it is way cleaner to test e.g. whether the source.exist() before trying to read form it. This way a FileNotFoundException is prevented and we do not need to catch them.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
Re: [jira] Commented: (FOR-914) [Java Coding] Do not raise
exception when you can prevent them
Posted by Thorsten Scherler <th...@wyona.com>.
El vie, 04-08-2006 a las 05:07 -0700, Tim Williams (JIRA) escribió:
> [ http://issues.apache.org/jira/browse/FOR-914?page=comments#action_12425730 ]
>
> Tim Williams commented on FOR-914:
> ----------------------------------
>
> +1, though I'm probably as guilty as the next person;(
> Some reference material:
> http://www.javaworld.com/jw-08-2000/jw-0818-exceptions.html
Thanks for this nice link.
"So, following the general philosophy behind exceptions, should you
dismiss the possibility that searches will return nothing? When a search
comes up empty, is it not more a case of normal processing? Therefore,
in order to use exceptions judiciously, choose the approach in Case 2
over Case 1."
Hit the nail on the head.
salu2
--
Thorsten Scherler
COO Spain
Wyona Inc. - Open Source Content Management - Apache Lenya
http://www.wyona.com http://lenya.apache.org
thorsten.scherler@wyona.com thorsten@apache.org