You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Ugo Cei <ug...@apache.org> on 2004/04/16 00:02:48 UTC
[VOTE] Make ProcessingException extend CascadingRuntimeException
I think everyone interested has had the option of venting his opinion
on the subject of checked vs. unchecked exceptions. For the record,
here [1] is the relevant thread.
In order to move forward, I propose to reparent the
org.apache.cocoon.ProcessingException to extend
org.apache.avalon.framework.CascadingRuntimeException instead of
CascadingException.
The change is backward-compatible and is a one-line change that can be
reverted easily, but might have implications on the way we manage
exceptions in the future.
I've already performed the change locally and everything compiles.
Tests fail, but they failed also before the change :-(.
So, please cast your votes.
Ugo
[1] http://marc.theaimsgroup.com/?t=108188608400002&r=1&w=2
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Bertrand Delacretaz <bd...@codeconsult.ch>.
Le 16 avr. 04, à 00:02, Ugo Cei a écrit :
> ...In order to move forward, I propose to reparent the
> org.apache.cocoon.ProcessingException to extend
> org.apache.avalon.framework.CascadingRuntimeException instead of
> CascadingException....
+1
-Bertrand
Re: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <ug...@apache.org>.
Il giorno 20/apr/04, alle 19:52, Nicola Ken Barozzi ha scritto:
> In any case, we need our guidelines.
>
+1 ;-).
Ugo
Re: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Nicola Ken Barozzi <ni...@apache.org>.
Ugo Cei wrote:
> Il giorno 20/apr/04, alle 18:55, Nicola Ken Barozzi ha scritto:
>
>> These rules are the ones that came out of HTTPD land, and reflect a
>> codebase that changes very differently from ours. What you should
>> really be looking at is: http://xml.apache.org/decisions.html
>
> I had already looked there, but that page strikes me as a wierd mix of
> circular and incomplete definitions.
For me, this is a majority vote. If it were a consensus vote, I'd have
voted -0.
My rule of the thumb:
1 - a veto generally applies to cvs commits that are dangerous and that
can be technically demonstrated to be so
2 - all other votes are majority
3 - if a majority vote is split, try to get more consensus
4 - if it's a minor thing, just do it, and don't ask a vote. At most
just a heads up and go for it.
In any case, we need our guidelines.
--
Nicola Ken Barozzi nicolaken@apache.org
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
Re: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <ug...@apache.org>.
Il giorno 20/apr/04, alle 19:40, Leo Sutic ha scritto:
> My personal guideline is this: If you have -1's you don't have
> consensus.
>
> Unless you have consensus, you shouldn't implement whatever
> it is you propose.
I'm inclined to refrain from making this change now. The vote is more
or less split, with only a small majority pro, and the issue is not
that important.
My opinion, as already mentioned, is that we should drop checked
exceptions for good. If I cannot even convince more than four people
that we should at least change one exception type, it's better to wait.
Maybe, one day, I'll write my own framework and host Cocoon in it, so I
can have it my way. Hey, that's an idea: make Cocoon independent of the
actual framework by using a meta-framework that insulates components
from the implementation details of the container. There should be a
standard for it, so that we might host Cocoon inside Avalon, Spring,
Nanocontainer, Picocontainer, whatever ... ;-).
Ugo
RE: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Leo Sutic <le...@inspireinfrastructure.com>.
These things were discussed to death at Avalon.
My personal guideline is this: If you have -1's you don't have
consensus.
Unless you have consensus, you shouldn't implement whatever
it is you propose.
As for the problem with someone being completely uncooperative,
well...
/LS
> From: Ugo Cei [mailto:ugo@apache.org]
Re: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <ug...@apache.org>.
Il giorno 20/apr/04, alle 18:55, Nicola Ken Barozzi ha scritto:
> These rules are the ones that came out of HTTPD land, and reflect a
> codebase that changes very differently from ours. What you should
> really be looking at is: http://xml.apache.org/decisions.html
I had already looked there, but that page strikes me as a wierd mix of
circular and incomplete definitions.
"An action requiring consensus approval must receive at least 3 binding
+1 votes and no binding vetos. An action requiring majority approval
must receive at least 3 binding +1 votes and more +1 votes than -1
votes. All other action items are considered to have lazy approval
until somebody votes - 1, after which point they are decided by either
consensus or majority vote, depending on the type of action item."
[...]
"Product Changes
Changes to the products of the Project, including code and
documentation, will appear as action items in the status file. All
product changes to the currently active repository are subject to lazy
consensus."
We clearly have a product change, here, which is subject to lazy
consensus until someone votes -1, which happpened, after which point it
is decided depending on the type of action item, which is subject to
lazy consensus until someone votes -1, which happpened, after which
point it is decided depending on the type of action item, which ... I'm
afraid.......I'm afraid, Dave. ;-)
Ugo
Re: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Nicola Ken Barozzi <ni...@apache.org>.
Ugo Cei wrote:
> Nicola Ken Barozzi wrote:
>
>> Ugo Cei wrote:
>>
>>> Nicola Ken Barozzi wrote:
>>>
>>>>> Should we interpret this as a veto?
>>>>
>>>> It's not up to interpretation, as nobody can veto [VOTE]s.
>>>>
>>>> Vetos can only be used to revert commits that should not happen
>>>> because of problems they generate, and be accompanied with solid
>>>> technical reasons.
>>>
>>> Thank you for the clarification. I did look around for an exhaustive
>>> and unambiguous description of our voting procedures, but couldn't
>>> find any. Do you have any pointers?
>>
>> http://incubator.apache.org/learn/voting.html
>
> Hmmm...
>
> "Under normal (non-lazy consensus) conditions, the proposal requires
> three positive votes and no negative ones in order to pass; [...]
> For code-modification votes, +1 votes are in favour of the proposal, but
> -1 votes are vetos and kill the proposal dead until all vetoers
> withdraw their -1 votes."
>
> Doesn't this apply to this vote?
I knew you would ask ;-)
These rules are the ones that came out of HTTPD land, and reflect a
codebase that changes very differently from ours. What you should really
be looking at is: http://xml.apache.org/decisions.html
We should have our own voting guidelines... where are they?
--
Nicola Ken Barozzi nicolaken@apache.org
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
Re: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <u....@cbim.it>.
Nicola Ken Barozzi wrote:
> Ugo Cei wrote:
>
>> Nicola Ken Barozzi wrote:
>>
>>>> Should we interpret this as a veto?
>>>
>>>
>>> It's not up to interpretation, as nobody can veto [VOTE]s.
>>>
>>> Vetos can only be used to revert commits that should not happen
>>> because of problems they generate, and be accompanied with solid
>>> technical reasons.
>>
>>
>> Thank you for the clarification. I did look around for an exhaustive
>> and unambiguous description of our voting procedures, but couldn't
>> find any. Do you have any pointers?
>
>
> http://incubator.apache.org/learn/voting.html
>
Hmmm...
"Under normal (non-lazy consensus) conditions, the proposal requires
three positive votes and no negative ones in order to pass; [...]
For code-modification votes, +1 votes are in favour of the proposal, but
-1 votes are vetos and kill the proposal dead until all vetoers
withdraw their -1 votes."
Doesn't this apply to this vote?
Ugo
Re: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Nicola Ken Barozzi <ni...@apache.org>.
Ugo Cei wrote:
> Nicola Ken Barozzi wrote:
>
>>> Should we interpret this as a veto?
>>
>> It's not up to interpretation, as nobody can veto [VOTE]s.
>>
>> Vetos can only be used to revert commits that should not happen
>> because of problems they generate, and be accompanied with solid
>> technical reasons.
>
> Thank you for the clarification. I did look around for an exhaustive and
> unambiguous description of our voting procedures, but couldn't find any.
> Do you have any pointers?
http://incubator.apache.org/learn/voting.html
--
Nicola Ken Barozzi nicolaken@apache.org
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
Re: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <u....@cbim.it>.
Nicola Ken Barozzi wrote:
>> Should we interpret this as a veto?
>
> It's not up to interpretation, as nobody can veto [VOTE]s.
>
> Vetos can only be used to revert commits that should not happen because
> of problems they generate, and be accompanied with solid technical reasons.
Thank you for the clarification. I did look around for an exhaustive and
unambiguous description of our voting procedures, but couldn't find any.
Do you have any pointers?
Ugo
Re: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Nicola Ken Barozzi <ni...@apache.org>.
Ugo Cei wrote:
> Il giorno 19/apr/04, alle 20:43, Joerg Heinicke ha scritto:
>
>> Joerg -1
>
> Should we interpret this as a veto?
It's not up to interpretation, as nobody can veto [VOTE]s.
Vetos can only be used to revert commits that should not happen because
of problems they generate, and be accompanied with solid technical reasons.
--
Nicola Ken Barozzi nicolaken@apache.org
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
Re: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Vadim Gritsenko <va...@reverycodes.com>.
Joerg Heinicke wrote:
> On 19.04.2004 22:36, Ugo Cei wrote:
>
>> Il giorno 19/apr/04, alle 20:43, Joerg Heinicke ha scritto:
>>
>>> Joerg -1
>>
>>
>> Should we interpret this as a veto?
>
>
> Ah, no, I do not see myself that important :) Just another -1.
Add another -1 from me. I'm with Nicola here, it provides more value to
fix erroneous exception handling on case by case basis.
Vadim
Re: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Joerg Heinicke <jo...@gmx.de>.
On 19.04.2004 22:36, Ugo Cei wrote:
> Il giorno 19/apr/04, alle 20:43, Joerg Heinicke ha scritto:
>
>> Joerg -1
>
> Should we interpret this as a veto?
Ah, no, I do not see myself that important :) Just another -1.
Joerg
Re: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <ug...@apache.org>.
Il giorno 19/apr/04, alle 20:43, Joerg Heinicke ha scritto:
> Joerg -1
Should we interpret this as a veto?
Ugo
Re: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Joerg Heinicke <jo...@gmx.de>.
On 19.04.2004 20:15, Ugo Cei wrote:
> Here are the results so far:
>
> Bertrand +1
> Berin +1
> Unico +1
> Stephan +1
> myself +1
> Marc 0
> Geoff 0
> Nicola Ken -1
> Leo Sutic +1 (non binding)
Joerg -1
RE: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Leo Sutic <le...@inspireinfrastructure.com>.
> From: Ugo Cei [mailto:u.cei@cbim.it]
> > Therefore, ProcessingException should really be ProcessingError -
> > since you're not expected to recover from it. Or extend Throwable
> > directly.
>
> Well that's more radical than my proposal! You won't catch it even if
> you do "catch(Exception e)".
That's the point. A ProcessingException means that all elements of the
pipeline should just *stop*. They shouldn't try to recover (IoC),
proceed
(IoC) or try some backup solution (IoC again). Just stop, exit, and let
the Processor/sitemap logic handle it.
> I warn you that even Sun is not sure about what constitutes
> an Error, as in the Javadoc it says:
>
> "An Error is a subclass of Throwable that indicates serious problems
> that a reasonable application should not try to catch.
I think that fits ProcessingException just fine.
The JavaDoc talks about "application", but you should understand this
in the proper context. If your code is a Cocoon component, then you
should read
this as: "An Error is a subclass of Throwable that indicates serious
problems
that a reasonable Cocoon component should not try to catch."
I.e. the meaning of "application" is highly context-dependent. What we
have done is to create an application environment - call it Cocoon OS if
you want - where you run web applications consisting of components. Just
because you don't launch something from the command line doesn't mean
that
it isn't an application.
/LS
Re: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <u....@cbim.it>.
Leo Sutic wrote:
> I change my non-binding vote to -1.
>
> Motivation:
>
> When you have a block of code that uses other modules, you often end up
> doing:
>
> try {
> ...
> } catch (Exception e) {
> // Whatever the cause, it didn't work.
> throw new MyException (e);
> }
>
> Since RuntimeException isa Exception, this will catch and wrap
> RuntimeExceptions as well.
As it catches ProcessingException now.
> This sort-of defeats what we're trying to achieve with
> ProcessingException,
> which is to make it bypass all wrapping and so on and go directly to the
> bottom of the stack.
>
> Therefore, ProcessingException should really be ProcessingError - since
> you're not expected to recover from it. Or extend Throwable directly.
Well that's more radical than my proposal! You won't catch it even if
you do "catch(Exception e)".
I warn you that even Sun is not sure about what constitutes an Error, as
in the Javadoc it says:
"An Error is a subclass of Throwable that indicates serious problems
that a reasonable application should not try to catch. Most such errors
are abnormal conditions. The ThreadDeath error, though a "normal"
condition, is also a subclass of Error because most applications should
not try to catch it."
But then you see javax.xml.parsers.FactoryConfigurationError extends Error.
Really makes you wonder whether all this mess about
Throwable/Error/Exception/RuntimeException does make any sense.
In the end, it just reinforces my conclusion: checked exceptions suck.
Gosling had good intentions but, as they say, the road to hell is paved
with good intentions. They do not work in practice, as nobody will ever
agree as to what constitutes a programming error, an abnormal condition
or a recoverable cause.
I am pretty sure that if we forgot about checked exceptions, we'd have
less verbose code, easier to understand and maintain. I am also sure
that it will take some time before this "heresy" becomes mainstream.
Ugo
RE: [VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Leo Sutic <le...@inspireinfrastructure.com>.
I change my non-binding vote to -1.
Motivation:
When you have a block of code that uses other modules, you often end up
doing:
try {
...
} catch (Exception e) {
// Whatever the cause, it didn't work.
throw new MyException (e);
}
Since RuntimeException isa Exception, this will catch and wrap
RuntimeExceptions as well.
This sort-of defeats what we're trying to achieve with
ProcessingException,
which is to make it bypass all wrapping and so on and go directly to the
bottom of the stack.
Therefore, ProcessingException should really be ProcessingError - since
you're not expected to recover from it. Or extend Throwable directly.
/LS
> From: Ugo Cei [mailto:ugo@apache.org]
[VOTE RESULTS] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <ug...@apache.org>.
Here are the results so far:
Bertrand +1
Berin +1
Unico +1
Stephan +1
myself +1
Marc 0
Geoff 0
Nicola Ken -1
Leo Sutic +1 (non binding)
I'll let the vote run for 24 more hours. In the meantime, let me know
if there are any errors in the summary.
Ugo
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Berin Loritsch <bl...@d-haven.org>.
Ugo Cei wrote:
> I think everyone interested has had the option of venting his opinion on
> the subject of checked vs. unchecked exceptions. For the record, here
> [1] is the relevant thread.
>
> In order to move forward, I propose to reparent the
> org.apache.cocoon.ProcessingException to extend
> org.apache.avalon.framework.CascadingRuntimeException instead of
> CascadingException.
>
> The change is backward-compatible and is a one-line change that can be
> reverted easily, but might have implications on the way we manage
> exceptions in the future.
>
> I've already performed the change locally and everything compiles. Tests
> fail, but they failed also before the change :-(.
>
> So, please cast your votes.
+1 from me.
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Geoff Howard <co...@leverageweb.com>.
Ugo Cei wrote:
> Geoff Howard wrote:
>
>> If the end-result of this is users seeing more stacktraces, or plain
>> 404 or 500 errors, I go -1.
>
> Users should see *shorter* and more meaningful stacktraces.
No, that was my point. Developers should see shorter more meaningful
stacktraces. Users should never see a stack trace in my opinion. I know this
is a semantic difference between "users" of the cocoon framework, and users of
the applications they build. I thought what you are proposing is not in
conflict with this, but I didn't have time to figure that out myself, hence my
comment.
>> If the end result is developers can still "catch" errors in the
>> sitemap and display custom "oops" pages instead (as currently) then I
>> go to +0.
>
> There is no plan to remove "catch" clauses from the sitemap processor,
> so the usual <map:handle-errors> should still work as usual.
There you go. Sorry you had to spell it out explicitly.
>> If, however, this means backwards incompatibility or behavior change
>> with existing components (external too, not only in our cvs) then I go
>> back to -1 no matter what.
>
> Removing a checked exception from the "throws" clause of a method
> declaration is a backward-compatible change.
>
> However, if we later on decide that this was not a good idea after all,
> readding a checked exception is backward-incompatible. This would only
> affect people who wrote code, calling this method without a try-catch
> block, in the interval between the two changes. I think that this is
> quite improbable and easily caught.
>
> Hope this clears your doubts.
I think this is probably OK risk. I'm on +0 now.
Geoff
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <u....@cbim.it>.
Geoff Howard wrote:
> If the end-result of this is users seeing
> more stacktraces, or plain 404 or 500 errors, I go -1.
Users should see *shorter* and more meaningful stacktraces.
> If the end
> result is developers can still "catch" errors in the sitemap and display
> custom "oops" pages instead (as currently) then I go to +0.
There is no plan to remove "catch" clauses from the sitemap processor,
so the usual <map:handle-errors> should still work as usual.
>If,
> however, this means backwards incompatibility or behavior change with
> existing components (external too, not only in our cvs) then I go back
> to -1 no matter what.
Removing a checked exception from the "throws" clause of a method
declaration is a backward-compatible change.
However, if we later on decide that this was not a good idea after all,
readding a checked exception is backward-incompatible. This would only
affect people who wrote code, calling this method without a try-catch
block, in the interval between the two changes. I think that this is
quite improbable and easily caught.
Hope this clears your doubts.
Ugo
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Geoff Howard <co...@leverageweb.com>.
Ugo Cei wrote:
> I think everyone interested has had the option of venting his opinion on
> the subject of checked vs. unchecked exceptions. For the record, here
> [1] is the relevant thread.
>
> In order to move forward, I propose to reparent the
> org.apache.cocoon.ProcessingException to extend
> org.apache.avalon.framework.CascadingRuntimeException instead of
> CascadingException.
>
> The change is backward-compatible and is a one-line change that can be
> reverted easily, but might have implications on the way we manage
> exceptions in the future.
>
> I've already performed the change locally and everything compiles. Tests
> fail, but they failed also before the change :-(.
>
> So, please cast your votes.
>
> Ugo
>
> [1] http://marc.theaimsgroup.com/?t=108188608400002&r=1&w=2
I have next to no time to follow the discussion, or comment fully, but I lean to
-.5 because I have a feeling that the thought process is too geared to how
developers want to see errors, not how developers should want users to see
errors. If the end-result of this is users seeing more stacktraces, or plain
404 or 500 errors, I go -1. If the end result is developers can still "catch"
errors in the sitemap and display custom "oops" pages instead (as currently)
then I go to +0. If, however, this means backwards incompatibility or behavior
change with existing components (external too, not only in our cvs) then I go
back to -1 no matter what.
Geoff
RE: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Leo Sutic <le...@inspireinfrastructure.com>.
I'm not a committer, but +1 from me.
The ProcessingException isn't supposed to be caught by the immediate
client, but propagated all the way up the stack. It therefore seems
unneccessary to burden the intermediate layers with having to declare
"throws ProcessingException".
/LS
> From: Unico Hommes [mailto:unico@hippo.nl]
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Unico Hommes <un...@hippo.nl>.
Nicola Ken Barozzi wrote:
> Ugo Cei wrote:
>
>> Nicola Ken Barozzi wrote:
>>
>>> In any case (and note that this is a vote, not a veto) the main
>>> reason is that in doing this we risk to throw out the baby with the
>>> water: I prefer a lot to remove ProcessingExceptions comptely and
>>> have the Cocoon components throw all the exceptions that the
>>> container can and will handle. IOW, I don't want to have an implicit
>>> contract but a more detailed and explicit one. In any case, generic
>>> ProcessingExceptions are evil, and this is a fact that we have known
>>> for a long time.
>>
>>
>> We have something worse than generic ProcessingExceptions being
>> thrown, we have components throwing CascadingException. Which not
>> only force clients to check them, but create an unnecessary
>> dependence on Avalon.
>
>
> Whaich I agree with, but still it's not about checked VS unchecked.
>
>> And I'm not going to throw out any baby. I'm going to throw out lots
>> of totally useless "catch" clauses that do nothing but litter the code.
>
>
> You don't need to use unchecked exceptions to do that. I don't see the
> connection.
>
The connection is fairly obvious to me. If you want to throw out the
useless catch clauses (which really are useless, I don't think you are
challenging that?) then there are two options. Either declare all
possible exception types in the method declaration (which in practice
means declaring throws Exception in the interface) or convert checked
exceptions to unchecked ones. Since the semantic value of the former is
nearly nil I personally see that option not adding a lot of value, just
more clog.
+1 for Ugo's proposal from me.
--
Unico
Re: Restating the Exception Problem (was Re: [VOTE] Make ProcessingException
extend CascadingRuntimeException)
Posted by Berin Loritsch <bl...@d-haven.org>.
Ugo Cei wrote:
>> a more serious issue. You cannot go by the type of exception alone.
>> By allowing the ProcessingException to have this additional
>> information embedded, the Sitemap can better handle creating more
>> accurate error pages.
>
>
> I'm confused here. Doesn't it already have it embedded?
only by exception heirarchy. For instance, the
ResourceNotFoundException is a Processing exception, which provides the
hint that it is a 404 error.
Now it would be just as easy to allow the embedding of an error code so
that we can handle any arbitrary issue. Another example is the 403
authorization error. I don't think we have a specific exception for that.
According to what I see:
http://cvs.apache.org/viewcvs.cgi/cocoon-2.2/src/java/org/apache/cocoon/ProcessingException.java?view=markup
There is no get/set error code for the exception. Adding one is
backwards compatible, and then using the error code is something that
can be done in the sitemap.
Our exception inheritance structure would allow automatic setting of the
appropriate error code for that exception type so you don't loose the
convenience, but you can still handle error codes that aren't
specifically handled right now.
Re: Restating the Exception Problem (was Re: [VOTE] Make ProcessingException
extend CascadingRuntimeException)
Posted by Ugo Cei <u....@cbim.it>.
Berin Loritsch wrote:
> The core problem that the proposed vote was trying to solve was to
> remove the need to catch a ProcessingException if we are merely going to
> log and rethrow it.
Yes.
> Does the ProcessingException allow you to store any clues as to the type
> of error handling we need (i.e. HTTP 500 error message, HTTP 404 error
> message)? The answer is no. It does provide some extra code to output
> a better error message though.
The answer is (theoretically) yes. The ProcessingException probably
wraps the original exception, so you can retrieve it. However, if the PE
is wrapped in a SAXException, which maybe is wrapped in something else,
then it all becomes more difficult.
> So what is the best approach? If we remove the ProcessingException,
> then we now have a backwards incompatible change. The old components
> compiled against old interfaces won't load because there is no
> ProcessingException in the classpath. That is clearly not the best
> approach.
Of course, not.
> If we make ProcessingException a RuntimeException, then we
> maintain backwards compatibility, and the need to declare the exception.
> Old precompiled code will still work, but if you recompile against the
> new interfaces with no declared ProcessingException then you will have
> an upgrade problem.
This if you remove the "throws ProcessingException" clause, but we won't
necessarily.
> a more serious issue. You cannot go by the type of exception alone. By
> allowing the ProcessingException to have this additional information
> embedded, the Sitemap can better handle creating more accurate error pages.
I'm confused here. Doesn't it already have it embedded?
Ugo
Restating the Exception Problem (was Re: [VOTE] Make ProcessingException
extend CascadingRuntimeException)
Posted by Berin Loritsch <bl...@d-haven.org>.
I am a little confused, it seemed like the direction of the discussion
on checked vs. unchecked exceptions was leading us down the path of this
vote. I realize that there are valid points on both sides of the issue,
so for my benefit and the benefit of everyone, I am going to try and
restate the problems trying to be solved so that we at least have a
common understanding. (I'm not there yet so it is probably more for my
benefit).
The core problem that the proposed vote was trying to solve was to
remove the need to catch a ProcessingException if we are merely going to
log and rethrow it.
The core problem that Nicola is concerned about is letting Cocoon
automatically handle the specific types of issues that it might need--in
essence removing the need for any type of Cocoon specific exception.
The goals are the same: to make it easier to write the components and
blocks and clean up the code.
Looking at the core components (Generator, Transformer, Serializer),
they declare a set of exception types that can be thrown:
Generator->IOException, SAXException, ProcessingException
Transformer->SAXException, IOException, ProcessingException
Serializer->IOException, ProcessingException
All of these can throw whatever exceptions are necessary. If any
exception is thrown, then the sitemap needs to handle it appropriately.
The next question is what is done differently in all these cases?
Does the ProcessingException allow you to store any clues as to the type
of error handling we need (i.e. HTTP 500 error message, HTTP 404 error
message)? The answer is no. It does provide some extra code to output
a better error message though.
So what is the best approach? If we remove the ProcessingException,
then we now have a backwards incompatible change. The old components
compiled against old interfaces won't load because there is no
ProcessingException in the classpath. That is clearly not the best
approach. If we make ProcessingException a RuntimeException, then we
maintain backwards compatibility, and the need to declare the exception.
Old precompiled code will still work, but if you recompile against the
new interfaces with no declared ProcessingException then you will have
an upgrade problem.
Of course there is another solution which is to add some information to
the ProcessingException that would give a better semantic clue to the
Sitemap the true nature of the problem and how best to translate that
into the error message pages. For example, a SQLException and an
IOException might signal that a resource is not found, or that there is
a more serious issue. You cannot go by the type of exception alone. By
allowing the ProcessingException to have this additional information
embedded, the Sitemap can better handle creating more accurate error pages.
Of course, if we declare all these exception types in the interfaces,
we should not have to catch them in the sitemap components. They should
be able to be handled in other ways.
If we declare a general throws clause of any Exception type, then we can
minimize the number of necessary catches completely.
If changing the ProcessingException to a RuntimeException will help
initially down this road, then I am all for it.
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <u....@cbim.it>.
Marc Portier wrote:
> What I'm buying here is clarity at the price of verbosity. A good deal
> over reduced kLOCs at the price of obscurity...
> IMHO: there are tools that help out with verbosity, for obscurity you're
> on your own :-(
This is fine, in theory. In practice, our codebase is full of rethrows
that add nothing to clarity.
> -marc= (doubthing there is an easy answer to this)
If there were, we'd all be programming in Eiffel ;-).
Ugo
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Marc Portier <mp...@outerthought.org>.
Ugo Cei wrote:
> Marc Portier wrote:
>
>> Ugo Cei wrote:
>>
>>> How about this?
>>>
>>> } catch (ProcessingException e) {
>>> getLogger().debug("Rethrowing exception", e);
>>> throw new SAXException(e);
>>> }
>>>
>>> This is not only useless, it's plain wrong.
>>
>>
>> why so?
>>
>> because SAXExceptions must be related to XML and it might be that this
>> ProcessingException was related to e.g. sql operations? And this
>> breaks with the 'IS A' test?
>>
>> I'm not sure: I think this depends on your understanding of what is
>> the meaning of a SAXException. Its purpose of existence is not to
>> communicate XML related errors, its purpose is to communicate to XML
>> processing components that they should stop doing so since
>> wellformedness of the communicated data (somewhere along the pipe) is
>> not ensured?
>
>
> I might agree with this. But if I were to agree completely, I would make
> SAXException unchecked, since, if XML processing components should stop
> processing, they might as well be interrupted by a runtime exception.
> How are they expected to recover from a malformed SAX stream?
>
oh, did I say they should stop?
I agree that the recovery component that would try to re-ensure XML
welformdness is highly hypothetical to the level of plain useless
but in more general terms: recovering from malformed sax stream could be
really easy: I'm reading in a configuration file through sax, if that is
bogus I switch to defaults... (I surely don't need to break completely,
and I'm quite glad the system reminded me of the fact that when dealing
with XML this issue is not to be totally overlooked)
> Well, in some cases you could, if you *really* must, but in practice
> very few components would need to. But now they are forced to deal with
> it by logging, wrapping and rethrowing.
>
but who are we to measure this awkwardness in our project in relation to
all other uses of SAX out there?
> But suppose we aren't given the luxury of catching a ProcessingException
> that we can ignore if we make it unchecked. Suppose we have to catch an
> SQLException, which we cannot change. Then, that's what I would do (if I
> were to agree with your reasoning above):
>
> catch (SQLException sqle) {
> throw new org.apache.cocoon.RuntimeSAXException
> ("While doing this and that:", sqle);
> }
>
> But since I'm not sure I completely agree with that reasoning, more
> probably I would do:
>
> catch (SQLException sqle) {
> throw new org.apache.cocoon.DataAccessException
> ("While doing this and that:", sqle);
> }
>
which fails to indicate that most likely the XML processing should be
stopped
I agree to do it like this if the above most likely does not stand, in
all other cases this will ensure a higher coupling up the call stack:
since someone up there will need to (and out of the blue) couple the
occurance of a DataAccessException to notyfing the SAX aware components
> The DataAccessException (unchecked) would have enough knowledge of
> SQLException to extract meaningful information from it, like SQL error
> codes and maybe even proprietary error codes (think Oracle, for
> instance). It would also have knowledge of other methods for accessing
> databases: JDO, Hibernate, etc. Thus, if you wanted to deal with data
> access exceptions in a persistence-layer-independent way, you could do:
>
> catch (DataAccessException dae) {
> // Extract enough information, if available, and see if we
> // can recover or not.
> }
>
agree, but higher up the chain is someone that doesn't know there are
databases involved, and doesn't want to: the only thing he knows is
SAXevents (and SAXexceptions) (he's not going to elegantly handle
database related things)
so why would that class ever provide this catch?
and if he catches RuntimeException instead, then what is the semantical
meaning of that?
and if he doesn't: how to just continue with the default config?
>> would this be your alternative then:
>> have a SAXWrappingProcessingException subclass that can only wrap a
>> SAXException that should be plainly unwrapped and rethrown in the case
>> that the context allows for it?
>>
>> } catch (SAXWrappingProcessingException e) {
>> throw e.getWrappedSAXException();
>> }
>> // not catching the ProsessingException will just let it propagate
>
> >
> > -marc= (still enthousiastically trying to be enthousiast)
>
> My alternative in this particulare instance is just to delete the three
> lines of code above. Aren't you enthusiastic about the prospect of
> removing unnecessary code? I usually am ;-).
>
hehe, me too, but I still fail to attach the label 'unnecessary'
specially if the price we pay is the introduction of higher-surprise
occurance of other code (i.e. when the DataAccessException occurs in a
spot that doesn't know about databases, but needs this clause to signal
the XML aware components so they can safely recover...)
What I'm buying here is clarity at the price of verbosity. A good deal
over reduced kLOCs at the price of obscurity...
IMHO: there are tools that help out with verbosity, for obscurity you're
on your own :-(
-marc= (doubthing there is an easy answer to this)
--
Marc Portier http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at http://blogs.cocoondev.org/mpo/
mpo@outerthought.org mpo@apache.org
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <u....@cbim.it>.
Marc Portier wrote:
> Ugo Cei wrote:
>
>> How about this?
>>
>> } catch (ProcessingException e) {
>> getLogger().debug("Rethrowing exception", e);
>> throw new SAXException(e);
>> }
>>
>> This is not only useless, it's plain wrong.
>
> why so?
>
> because SAXExceptions must be related to XML and it might be that this
> ProcessingException was related to e.g. sql operations? And this breaks
> with the 'IS A' test?
>
> I'm not sure: I think this depends on your understanding of what is the
> meaning of a SAXException. Its purpose of existence is not to
> communicate XML related errors, its purpose is to communicate to XML
> processing components that they should stop doing so since
> wellformedness of the communicated data (somewhere along the pipe) is
> not ensured?
I might agree with this. But if I were to agree completely, I would make
SAXException unchecked, since, if XML processing components should stop
processing, they might as well be interrupted by a runtime exception.
How are they expected to recover from a malformed SAX stream?
Well, in some cases you could, if you *really* must, but in practice
very few components would need to. But now they are forced to deal with
it by logging, wrapping and rethrowing.
But suppose we aren't given the luxury of catching a ProcessingException
that we can ignore if we make it unchecked. Suppose we have to catch an
SQLException, which we cannot change. Then, that's what I would do (if I
were to agree with your reasoning above):
catch (SQLException sqle) {
throw new org.apache.cocoon.RuntimeSAXException
("While doing this and that:", sqle);
}
But since I'm not sure I completely agree with that reasoning, more
probably I would do:
catch (SQLException sqle) {
throw new org.apache.cocoon.DataAccessException
("While doing this and that:", sqle);
}
The DataAccessException (unchecked) would have enough knowledge of
SQLException to extract meaningful information from it, like SQL error
codes and maybe even proprietary error codes (think Oracle, for
instance). It would also have knowledge of other methods for accessing
databases: JDO, Hibernate, etc. Thus, if you wanted to deal with data
access exceptions in a persistence-layer-independent way, you could do:
catch (DataAccessException dae) {
// Extract enough information, if available, and see if we
// can recover or not.
}
> would this be your alternative then:
> have a SAXWrappingProcessingException subclass that can only wrap a
> SAXException that should be plainly unwrapped and rethrown in the case
> that the context allows for it?
>
> } catch (SAXWrappingProcessingException e) {
> throw e.getWrappedSAXException();
> }
> // not catching the ProsessingException will just let it propagate
>
> -marc= (still enthousiastically trying to be enthousiast)
My alternative in this particulare instance is just to delete the three
lines of code above. Aren't you enthusiastic about the prospect of
removing unnecessary code? I usually am ;-).
Ugo
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Marc Portier <mp...@outerthought.org>.
Ugo Cei wrote:
> How about this?
>
> } catch (ProcessingException e) {
> getLogger().debug("Rethrowing exception", e);
> throw new SAXException(e);
> }
>
> This is not only useless, it's plain wrong.
>
why so?
because SAXExceptions must be related to XML and it might be that this
ProcessingException was related to e.g. sql operations? And this breaks
with the 'IS A' test?
I'm not sure: I think this depends on your understanding of what is the
meaning of a SAXException. Its purpose of existence is not to
communicate XML related errors, its purpose is to communicate to XML
processing components that they should stop doing so since
wellformedness of the communicated data (somewhere along the pipe) is
not ensured?
would this be your alternative then:
have a SAXWrappingProcessingException subclass that can only wrap a
SAXException that should be plainly unwrapped and rethrown in the case
that the context allows for it?
} catch (SAXWrappingProcessingException e) {
throw e.getWrappedSAXException();
}
// not catching the ProsessingException will just let it propagate
-marc= (still enthousiastically trying to be enthousiast)
--
Marc Portier http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at http://blogs.cocoondev.org/mpo/
mpo@outerthought.org mpo@apache.org
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Bertrand Delacretaz <bd...@apache.org>.
Le 16 avr. 04, à 15:28, Marc Portier a écrit :
> ...I'm not currently not convinced there could be anything else then
> careful consideration on each point in the code, sorry if this is bad
> news....
I tend to agree.
I don't have time currently to seriously follow the discussion, but a
quick random thought: would interfaces help in deciding what must be
caught and what not?
for example:
class SitemapParsingProblemException
extends ProcessingException
implements XmlParsingException, SitemapSyntaxException
WDYT?
-Bertrand
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Marc Portier <mp...@outerthought.org>.
Ugo Cei wrote:
> Nicola Ken Barozzi wrote:
>
>> Ugo Cei wrote:
>>
>>> For 2.2 (which we have agreed will require JDK 1.4 IIRC, so we can
>>> count on exception chaining) I will propose to define a
>>> Cocoon-specific hierarchy of exceptions, whose root is
>>> java.lang.RuntimeException. And 3rd party exception classes like
>>> SAXException will have to be wrapped inside Cocoon-specific runtime
>>> exceptions.
>>
>> Gaaak! Why so? I just don't get it, you don't like wrapping but are
>> going to do it nevertheless?
>
>
> I'm going to wrap only if I'm forced to or it adds value, i.e.
> information. Not just because I am forced by a "throws" clause in a
> method signature.
>
> If there's no "throws", I get to decide whether to wrap or not.
>
which sounds like more arbitrary decissions and thus 'surprise-code'
I will be left to wonder why you suddenly wrap it now?
and the answer will be only in the fact that somebody further up your
call-stack has a special handling case for this?
>>> How about this?
>>>
>>> } catch (ProcessingException e) {
>>> getLogger().debug("Rethrowing exception", e);
>>> throw new SAXException(e);
>>> }
>>>
>>> This is not only useless, it's plain wrong.
>>
>>
>> First of all, why are you logging? Useless.
>
>
> Me? This is not code I wrote, it's in our CVS.
>
> I'm not into pshychic reading, but it seems to me quite evident that
> whoever wrote that code was feeling somewhat helpless or even guilty: "I
> don't know what to do with this ProcessingException that I'm *forced* to
> catch by the compiler, so I'm going to log it to share the burden of my
> guilt". But the author should not blame himself of feel guilty. He
> should blame the fact that ProcessingException is checked.
hm, slightly exagerated? IMHO there is an equal drive to do this logging
coming from the fact that the class was LogEnabled :-)
>
> Do you know what this is? This is a _code_ _smell_ and I want to remove it.
>
> Obviously, you appreciate checked exceptions more than I do, and there's
> nothing wrong with that. You are in Gosling's camp, and probably the
> majority of programmers is with you. I'm not going to change your mind
> and make you switch over to Eckel's camp in the space of a maling list
> thread.
>
Ugo, I don't think this is about camps, at least not in my head, I
really found the Eckel's view and enteresting read and a pure
revelation: I find it to broaden my view on the issue (in general)
As I tried to mention before: general views can help us see, but we have
to look into our project-details ourselves.
> But let's be pragmatic. We have an *evident* code smell (I hope you at
> least agree with me on this point) and want to remove it. My pragmatic
> approach is: make ProcessingException extend CascadingRuntimeException,
> find all the lines of code that match this template:
>
> catch (ProcessingException e) {
> getLogger().*(*);
> throw new *Exception(*, e);
> }
>
> and simply remove them. *POOF* away goes the smell.
>
hehe, this makes me think about a humor-radio-program we had years ago
on belgian radio, people were asked to invent a perfect 'perfume'
turns out that was shaped like: [two plugs you put into your own nose]
removing the smell is admirable, making it smell good is better
> If you don't agree, then what is your proposal?
>
sigh, making it smell good is hard work, that's what I hinted at when
saying there is no easy answer...
I'm not currently not convinced there could be anything else then
careful consideration on each point in the code, sorry if this is bad news.
regards,
-marc=
--
Marc Portier http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at http://blogs.cocoondev.org/mpo/
mpo@outerthought.org mpo@apache.org
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Joerg Heinicke <jo...@gmx.de>.
On 17.04.2004 12:38, Nicola Ken Barozzi wrote:
> In any case, what I see is that Cocoon has gotten many contracts wrong.
> In particular it has been coded using generic Cocoonish exceptions that
> were meant to gobble up the source exceptions from the start. In fact we
> can say that what seems now as an error was deemed in the beginning as a
> feature, that was probably done to achieve that RuntimeExceptions do
> rather than to have what we have now.
>
> I would like to note BTW that my -1 is a vote, not a veto. It is based
> on the fact that I don't believe that using RuntimeExceptions will bring
> us that cleaness we need without unwanted consequences, but this is just
> MHO and I may well again be wrong, as it happens :-)
Same here. The change to RuntimeExceptions only circumvents the inherent
problem of Cocoon.
Joerg
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Nicola Ken Barozzi <ni...@apache.org>.
Ugo Cei wrote:
> Nicola Ken Barozzi wrote:
>
>> Since you know that we have dozens of places in the code with this
>> thing, do you care posting a dozen of them here?
Thanks for taking the time to do it. Now, let's try to analyze and see
what is the real use of them.
> AbstractCommandLineEnvironment.java:
>
> } catch (ProcessingException pe) {
> throw new CascadingIOException("ProcessingException: " + pe, pe);
> }
This is the whole relevant code snippet with my comment below (as in
mail replies) the commented sections:
/**
* Redirect the client to a new URL
*/
public void redirect(boolean sessionmode, String newURL)
throws IOException {
//NKB: Here it says that a redirect can throw only an IOException.
// What does this mean? It means that the caller of this can only handle
// a *generic* error on the IO, that is usually abort what it was doing.
// Hmmm...
[...]
// FIXME: this is a hack for the links view
if (newURL.startsWith("cocoon:")
&& this.getView() != null
&& this.getView().equals(Constants.LINK_VIEW)) {
[...]
Source redirectSource = null;
try {
redirectSource = this.resolveURI(newURL);
SourceUtil.parse( this.manager, redirectSource, ls);
//NKB: Here it says that it has to resolve an URL, but the process
// is not necessarily something that has success.
} catch (SourceException se) {
throw new CascadingIOException("SourceException: " +
se, se);
} catch (SAXException se) {
throw new CascadingIOException("SAXException: " + se, se);
} catch (ProcessingException pe) {
throw new CascadingIOException("ProcessingException: "
+ pe, pe);
} finally {
this.release( redirectSource );
}
[...]
//NKB: Here what we are doing is saying:
// " Some finer grained exceptions can occur, but we won't do anything
// about it. Instead I'll tell my parent that I cannot do my work."
Note a couple of things here:
1 - Reading the code I have no idea whatsoever about the
ProcessingException: we could as easily have made it Exception that it
has the same (lack of) meaning.
2 - The redirect takes an URL as a String, which is wrong. A method
should do one thing, not many. If it does many, it can fail in many
ways, but here there is only one way it can fail now: IOException.
So because of this the method should be:
public void redirect(boolean sessionmode, String newURL)
throws IOException, SourceException {
or
public void redirect(boolean sessionmode, Source newURL)
throws IOException {
The latter is definately preferrable.
In fact, for example, SitemapSource throws a MalformedURLException,
which should be called and thus dealt with by the caller.
3 - It redirects a SAX stream and cannot internally fail for an
IOException... then why does it throw one?
So because of this the method should be:
public void redirect(boolean sessionmode, String newURL)
throws SAXException {
If it were so, we would not have try/catch.
The problem with error handling here is that the contract is wrong.
> HTMLTransformer.java (this is wicked!):
>
> } catch (ProcessingException e) {
> e.printStackTrace();
> }
/**
* React on endElement calls that contain a tag to be
* tidied and run Jtidy on it, otherwise passthru.
*
* @see org.xml.sax.ContentHandler#endElement(java.lang.String,
java.lang.String, java.lang.String)
*/
public void endElement(String uri, String name, String raw)
throws SAXException {
if (this.tags.containsKey(name)) {
String toBeNormalized = this.endTextRecording();
try {
this.normalize(toBeNormalized);
} catch (ProcessingException e) {
//NKB: Here we are trying to normalize a tag, but can fail.
// What we want to do it not to fail even if the single step to
// *try* to clean it, fails.
e.printStackTrace();
}
}
super.endElement(uri, name, raw);
}
Hence it should be:
} catch (ProcessingException e) {
logger.debug("Cleaning tag failed. Continuing... ",e);
}
> DefaultHandlerManager.java:
>
> } catch (ProcessingException se) {
> throw new ConfigurationException("Exception during configuration of
> handler: " + name, se);
> }
[Below I snipped all ProcessingExceptions that actually have little
meaning. The wrong thing in particular happens because we catch a
generic ProcessingException and narrow it, like above...]
> } catch (ProcessingException pe) {
> throw new SAXException(pe);
> }
>
> CachingSource.java (does it three times):
>
> catch(ProcessingException e) {
> throw new CascadingIOException("Failure storing response.", e);
> }
[Or probably a contract mismatch instead, like above.]
[...]
> That's 23, then I stopped pasting. But considering all the catch clauses
> for ProcessingException and its subclasses we have:
>
> ProcessingException: 64 occurences
> ConnectionResetException: 4 occurences
> ResourceNotFoundException: 10 occurrences
>
> But ProcessingException is just one example. Avalon's CascadingException
> has 14 children exception classes. For instance,
> org.apache.avalon.framework.configuration.ConfigurationException, which
> is heavily used by CForms for doing things like:
>
> throw new ConfigurationException("Convertor defined in plain attribute
> unavailable.", e);
>
> Now, don't tell me that distributing an incorrect configuration file is
> not a programming error. Do contracts also cover the case of programming
> errors?
Yes, when there are different roles in deployment. The contract is
between the coder and the deployer, and usually they are different.
> I suspect this should be a runtime exception. Better yet, when
> we have Java 1.4 as a requirement, this should be:
>
> assert false, "Convertor defined in plain attribute unavailable.";
?
In any case, what I see is that Cocoon has gotten many contracts wrong.
In particular it has been coded using generic Cocoonish exceptions that
were meant to gobble up the source exceptions from the start. In fact we
can say that what seems now as an error was deemed in the beginning as a
feature, that was probably done to achieve that RuntimeExceptions do
rather than to have what we have now.
I would like to note BTW that my -1 is a vote, not a veto. It is based
on the fact that I don't believe that using RuntimeExceptions will bring
us that cleaness we need without unwanted consequences, but this is just
MHO and I may well again be wrong, as it happens :-)
--
Nicola Ken Barozzi nicolaken@apache.org
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Guido Casper <gc...@s-und-n.de>.
Ugo Cei wrote:
> Guido Casper wrote:
>
>> Ugo Cei wrote:
>>
>>> WebDAVRepository.java (swallowed):
>>>
>>> } catch (ProcessingException pe) {
>>> this.getLogger().error("Error saving dom to: " + this.repoBaseUrl
>>> + uri, pe);
>>> }
>>>
>>> WebDAVRepositoryPropertyHelper.java (swallowed):
>>>
>>> } catch (ProcessingException pe) {
>>> this.getLogger().error("Error serializing node " + value, pe);
>>> }
>>
>>
>>
>> Ehm, I didn't follow all the discussions very closely, but if you want
>> to remove something please be aware that these Exceptions are not just
>> swallowed (don't know about the others) since after the catch clause
>> follows a "return false;"
>
>
> Indeed, we should carefully check every one of the samples I have
> pasted, before changing them. Particularly those that don't rethrow an
> exception.
>
> At the very least, we can say that the usage of exceptions in this case
> looks suspiciously like an instance of controlling the flow of the
> application with exceptions.
Hmm, it seems to be conventional wisdom to use exceptions only for
exceptional cases. But what is the definition of an exceptional case
then (it's pretty clear what the "primary route" through this code is)?
Exceptions are also a way to prevent my code from cluttering by
constantly having to check return codes. And if you don't want every
single exception being thrown to the user you have to consume it somewhere.
>
> The problem is that the call that mandated the use of the "catch" might
> fail and throw a runtime exception (say, a NPE) instead. If you want the
> call to setProperty to always fail graciously, you'd better
> catch(Exception) instead, don't you agree?
I'm still in my opinion finding phase on this :-) (wether to make
ProcessingException a RuntimeException).
I think both "sides" have their points. In many cases it may be a matter
of where and how you want to consume your exceptions.
Catching fine grained Exceptions doesn't buy me much in this case
(except being able to put more meaningful messages into the logs).
Guido
--
Guido Casper
-------------------------------------------------
S&N AG, Competence Center Open Source
Tel.: +49-5251-1581-87
Klingenderstr. 5 mailto:gcasper@s-und-n.de
D-33100 Paderborn http://www.s-und-n.de
-------------------------------------------------
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <u....@cbim.it>.
Guido Casper wrote:
> Ugo Cei wrote:
>
>> WebDAVRepository.java (swallowed):
>>
>> } catch (ProcessingException pe) {
>> this.getLogger().error("Error saving dom to: " + this.repoBaseUrl
>> + uri, pe);
>> }
>>
>> WebDAVRepositoryPropertyHelper.java (swallowed):
>>
>> } catch (ProcessingException pe) {
>> this.getLogger().error("Error serializing node " + value, pe);
>> }
>
>
> Ehm, I didn't follow all the discussions very closely, but if you want
> to remove something please be aware that these Exceptions are not just
> swallowed (don't know about the others) since after the catch clause
> follows a "return false;"
Indeed, we should carefully check every one of the samples I have
pasted, before changing them. Particularly those that don't rethrow an
exception.
At the very least, we can say that the usage of exceptions in this case
looks suspiciously like an instance of controlling the flow of the
application with exceptions.
The problem is that the call that mandated the use of the "catch" might
fail and throw a runtime exception (say, a NPE) instead. If you want the
call to setProperty to always fail graciously, you'd better
catch(Exception) instead, don't you agree?
Ugo
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Guido Casper <gc...@s-und-n.de>.
Ugo Cei wrote:
> WebDAVRepository.java (swallowed):
>
> } catch (ProcessingException pe) {
> this.getLogger().error("Error saving dom to: " + this.repoBaseUrl +
> uri, pe);
> }
>
> WebDAVRepositoryPropertyHelper.java (swallowed):
>
> } catch (ProcessingException pe) {
> this.getLogger().error("Error serializing node " + value, pe);
> }
Ehm, I didn't follow all the discussions very closely, but if you want
to remove something please be aware that these Exceptions are not just
swallowed (don't know about the others) since after the catch clause
follows a "return false;"
Guido
--
Guido Casper
-------------------------------------------------
S&N AG, Competence Center Open Source
Tel.: +49-5251-1581-87
Klingenderstr. 5 mailto:gcasper@s-und-n.de
D-33100 Paderborn http://www.s-und-n.de
-------------------------------------------------
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <u....@cbim.it>.
Nicola Ken Barozzi wrote:
> Since you know that we have dozens of places in the code with this
> thing, do you care posting a dozen of them here?
AbstractCommandLineEnvironment.java:
} catch (ProcessingException pe) {
throw new CascadingIOException("ProcessingException: " + pe, pe);
}
HTMLTransformer.java (this is wicked!):
} catch (ProcessingException e) {
e.printStackTrace();
}
XMidiSerializer.java (does it twice):
} catch (ProcessingException e) {
throw new SAXException(e);
} catch (IOException e) {
AuthenticationContext.java (at least we rethrow a runtime exception here):
} catch (ProcessingException pe) {
throw new CascadingRuntimeException("Unable to create simple
context.", pe);
}
DefaultHandlerManager.java:
} catch (ProcessingException se) {
throw new ConfigurationException("Exception during configuration of
handler: " + name, se);
}
PipelineAuthenticator.java (might be legit here, but if it is, should
use "warn", shouldn't it?):
} catch (ProcessingException local) {
this.getLogger().error("authenticator: " + local.getMessage(), local);
exceptionMsg = local.getMessage();
}
XMLDBSource.java:
} catch (ProcessingException pe) {
throw new SAXException("ProcessingException", pe);
}
SQLTransformer.java (does it twice):
} catch (ProcessingException pe) {
throw new SAXException(pe);
}
CachingSource.java (does it three times):
catch(ProcessingException e) {
throw new CascadingIOException("Failure storing response.", e);
}
BookmarkAction.java:
} catch (ProcessingException se) {
throw new ParameterException("Unable to read configuration from " +
configurationFile, se);
} catch (SAXException se) {
ApplicationCopletAdapter.java (swallowed twice):
catch (ProcessingException ex) {
getLogger().error("Could not create new coplet instance", ex);
}
...
catch (ProcessingException pe) {
getLogger().error(
"Error while getting portal application configuration for coplet "
+ coplet.getId(),
pe);
}
DefaultLayoutFactory.java:
} catch (ProcessingException pe) {
throw new CascadingRuntimeException("Exception during removal.", pe);
}
BasketLayoutManagerImpl.java (swallowed three times, logged once):
} catch (ProcessingException pe) {
this.getLogger().warn("Unable to create new instance.", pe);
} catch (ServiceException se) {
DASLTransformer.java:
} catch (ProcessingException e) {
throw new SAXException("Unable to fetch the query data:", e);
}
WebDAVRepository.java (swallowed):
} catch (ProcessingException pe) {
this.getLogger().error("Error saving dom to: " + this.repoBaseUrl +
uri, pe);
}
WebDAVRepositoryPropertyHelper.java (swallowed):
} catch (ProcessingException pe) {
this.getLogger().error("Error serializing node " + value, pe);
}
That's 23, then I stopped pasting. But considering all the catch clauses
for ProcessingException and its subclasses we have:
ProcessingException: 64 occurences
ConnectionResetException: 4 occurences
ResourceNotFoundException: 10 occurrences
But ProcessingException is just one example. Avalon's CascadingException
has 14 children exception classes. For instance,
org.apache.avalon.framework.configuration.ConfigurationException, which
is heavily used by CForms for doing things like:
throw new ConfigurationException("Convertor defined in plain
attribute unavailable.", e);
Now, don't tell me that distributing an incorrect configuration file is
not a programming error. Do contracts also cover the case of programming
errors? I suspect this should be a runtime exception. Better yet, when
we have Java 1.4 as a requirement, this should be:
assert false, "Convertor defined in plain attribute unavailable.";
Ugo
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <u....@cbim.it>.
Nicola Ken Barozzi wrote:
> You are forced by a contract, just as you are forced by other types.
Personally, I don't buy this "design by contract" thing, I much prefer
"design by testing", or "Test Driven Design", if you prefer :-).
> He should blame the fact that he does not have ProcessingException in
> *it's* throws cause even if he cannot cope with it.
Since he's implementing an interface that doesn't declare it in its
"throws" clause, he has no choice.
> I never remove code smell. If it works, don't touch it, even if it
> smells. If it doesn't work, fix it. Code beauty and lack of odor only
> creates nice empty boxes, and I know something about it unfortunately.
I see we have widely divergent opinions on this. I believe that code
rots unless you continuously refactor it. I believe that you should fix
broken windows, even if you live in Barbados, before the whole house
starts crumbling down.
>> If you don't agree, then what is your proposal?
>
> catch (ProcessingException e) {
>
> //see if I *really* need to rethrow it
>
> throw new *Exception(*, e);
> }
Do you plan to go over our codebase and, for every such case, evaluate
if we *really* need to rethrow it?
> Get it right with 2.2 by defining the contract with the container, IE
> what the component.
Hmmm, maybe you truncated the sentence a little too early here: "what
the component ..."?
Anyway, my take on this is that trying to enumerate in a contract
everything that might possibly go wrong is impossible. But, as I said,
we have plenty of time to discuss this before 2.2. This call for votes
is for 2.1.
> Since you know that we have dozens of places in the code with this
> thing, do you care posting a dozen of them here?
OK, stay tuned.
Ugo
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Nicola Ken Barozzi <ni...@apache.org>.
Ugo Cei wrote:
> Nicola Ken Barozzi wrote:
>
>> Ugo Cei wrote:
>>
>>> For 2.2 (which we have agreed will require JDK 1.4 IIRC, so we can
>>> count on exception chaining) I will propose to define a
>>> Cocoon-specific hierarchy of exceptions, whose root is
>>> java.lang.RuntimeException. And 3rd party exception classes like
>>> SAXException will have to be wrapped inside Cocoon-specific runtime
>>> exceptions.
>>
>> Gaaak! Why so? I just don't get it, you don't like wrapping but are
>> going to do it nevertheless?
>
> I'm going to wrap only if I'm forced to or it adds value, i.e.
> information.
It should usually never add information. If it has more information than
the base, it can usually handle it completely.
> Not just because I am forced by a "throws" clause in a
> method signature.
You are forced by a contract, just as you are forced by other types.
> If there's no "throws", I get to decide whether to wrap or not.
Or you don't decide at all.
>>> How about this?
>>>
>>> } catch (ProcessingException e) {
>>> getLogger().debug("Rethrowing exception", e);
>>> throw new SAXException(e);
>>> }
>>>
>>> This is not only useless, it's plain wrong.
>>
>>
>> First of all, why are you logging? Useless.
>
> Me? This is not code I wrote, it's in our CVS.
I know, man. What I say is that the fact that it gets logged has
*nothing* to do with unchecked exceptions. It seems that for you one has
unchecked exceptions or the thing that you have written above. Stop
polluting the discussion with these things as they are not involved.
> I'm not into pshychic reading, but it seems to me quite evident that
> whoever wrote that code was feeling somewhat helpless or even guilty: "I
> don't know what to do with this ProcessingException that I'm *forced* to
> catch by the compiler, so I'm going to log it to share the burden of my
> guilt". But the author should not blame himself of feel guilty. He
> should blame the fact that ProcessingException is checked.
He should blame the fact that he does not have ProcessingException in
*it's* throws cause even if he cannot cope with it.
> Do you know what this is? This is a _code_ _smell_ and I want to remove it.
I never remove code smell. If it works, don't touch it, even if it
smells. If it doesn't work, fix it. Code beauty and lack of odor only
creates nice empty boxes, and I know something about it unfortunately.
> Obviously, you appreciate checked exceptions more than I do, and there's
> nothing wrong with that. You are in Gosling's camp, and probably the
> majority of programmers is with you. I'm not going to change your mind
> and make you switch over to Eckel's camp in the space of a maling list
> thread.
>
> But let's be pragmatic. We have an *evident* code smell (I hope you at
> least agree with me on this point) and want to remove it. My pragmatic
> approach is: make ProcessingException extend CascadingRuntimeException,
> find all the lines of code that match this template:
>
> catch (ProcessingException e) {
> getLogger().*(*);
> throw new *Exception(*, e);
> }
>
> and simply remove them. *POOF* away goes the smell.
Yeah, great, let's just remove the code.
> If you don't agree, then what is your proposal?
catch (ProcessingException e) {
//see if I *really* need to rethrow it
throw new *Exception(*, e);
}
or simply let it be rethrown if possible. I would prefer a lot to rather
add ProcessingException to the throws cause of these components, as this
is how it should have been done if the contract actually needs it.
PLUS
Get it right with 2.2 by defining the contract with the container, IE
what the component.
Since you know that we have dozens of places in the code with this
thing, do you care posting a dozen of them here?
--
Nicola Ken Barozzi nicolaken@apache.org
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Nicola Ken Barozzi <ni...@apache.org>.
Ugo Cei wrote:
...
>> And for the specific case of ProcessingExceptions: Does not almost
>> every of our
>> components have the ProcessingException in its throws clause? So where
>> is the
>> need for catching/wrapping/rethrowing them?? Only current bad usage is
>> not a reason for changing it IMO.
>
> The compiler forces you to catch them.
It does because it's part of the contract. We can agree that the current
contract is bad, but this does not mean that it must be thus completely
removed.
--
Nicola Ken Barozzi nicolaken@apache.org
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Berin Loritsch <bl...@d-haven.org>.
Joerg Heinicke wrote:
> On 16.04.2004 16:47, Ugo Cei wrote:
>
>> The conventional wisdom is that it's better to have the compiler
>> remind you that you have to catch most exceptions, because that's part
>> of the contract. My opinion, instead, is that checked exceptions are a
>> very bad way of enforcing contracts between callers and callees.
>
> This is where I don't follow you.
It's a question of where to handle the exceptions. Many projects have a
way of handling arbitrary exceptions that slip through the cracks.
Checked exceptions encourage handling the exception as close to the
cause as possible. Unchecked exceptions encourage global exception
handling.
In many situations, allowing exceptions to be propagated to the sitemap
would actually be preferred. Most examples in the cocoon codebase seem
to support that notion. There are times where it does make sense to
handle close to the cause of the exception, but that is usually only
when you have an alternative way to get the information.
> What I hate in Java are untyped collections, that force me to cast when
> retrieving an object out of them, and long vs. Long (was it called
> auto-boxing?). Both will be fixed in Java 1.5 IIRC.
Be careful with this. In my initial testing with Java 1.5, it is still
quite easy to circumvent typed collections. I highly recommend using
the "-Xlint:all" command line argument for the javac compiler. It will
warn you if you cast a typed collection to an untyped collection.
It does clean up a lot of cruft in your code that makes it really nice.
Not to mention the new java.lang.StringBuilder will also provide more
optimization. The only difference between StringBuilder and
StringBuffer is that the StringBuilder is unsynchronized--it is finally
offered because most usages of StringBuffer are all within the same
thread. Lower thread contention means faster runtime.
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Joerg Heinicke <jo...@gmx.de>.
On 16.04.2004 16:47, Ugo Cei wrote:
>>> The compiler forces you to catch them.
>>
>> Of course, but only exactly once at the end. How are the exceptions made
>> available to handle-errors at the moment? I guess somewhere in the tree
>> processor. So where is the problem letting it catch the exception? I
>> still don't
>> see the need for the re-parenting.
>
> No. Assuming there are several layers, currently the compiler forces you
> to catch the exception at every layer or declare it in the throws clause
> (which might be impossible if you're implementing an interface).
>
> On the contrary, if PE extends RuntimeCascadingException, you have the
> freedom to catch it only in the outermost layer, that would probably be
> the sitemap processor. Or you can catch it wherever you like.
>
> The conventional wisdom is that it's better to have the compiler remind
> you that you have to catch most exceptions, because that's part of the
> contract. My opinion, instead, is that checked exceptions are a very bad
> way of enforcing contracts between callers and callees.
This is where I don't follow you.
> The conventional wisdom is also that strong type checking helps in
> enforcing contracts. Judging from the recent flourishing of untpyed or
> weakly-typed languages like Python, Ruby, Groovy or Javascript [1], I'd
> be inclined to doubt that wisdom too.
Same here. Do you remember this one:
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=107901388024464&w=4 ??
If I change the implementation to a Set the statement will fail. I need
many more tests than with strong-typing. But the same way I do not want
to care about request and form handling - I use an abstracting framework
for it, and care only about business logic - I do not want to care about
testing correct types. The only tests I want to write are about business
logic.
What I hate in Java are untyped collections, that force me to cast when
retrieving an object out of them, and long vs. Long (was it called
auto-boxing?). Both will be fixed in Java 1.5 IIRC.
Joerg
> [1] :
>
> function myflow() {
> var obj = cocoon.getComponent(id);
> obj.someMethodThrowingCheckedException();
> // What? No cast? No try-catch? Where's the compiler??? ;-)
> }
>
>
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <u....@cbim.it>.
Joerg Heinicke wrote:
>>The compiler forces you to catch them.
> Of course, but only exactly once at the end. How are the exceptions made
> available to handle-errors at the moment? I guess somewhere in the tree
> processor. So where is the problem letting it catch the exception? I still don't
> see the need for the re-parenting.
No. Assuming there are several layers, currently the compiler forces you
to catch the exception at every layer or declare it in the throws clause
(which might be impossible if you're implementing an interface).
On the contrary, if PE extends RuntimeCascadingException, you have the
freedom to catch it only in the outermost layer, that would probably be
the sitemap processor. Or you can catch it wherever you like.
The conventional wisdom is that it's better to have the compiler remind
you that you have to catch most exceptions, because that's part of the
contract. My opinion, instead, is that checked exceptions are a very bad
way of enforcing contracts between callers and callees.
The conventional wisdom is also that strong type checking helps in
enforcing contracts. Judging from the recent flourishing of untpyed or
weakly-typed languages like Python, Ruby, Groovy or Javascript [1], I'd
be inclined to doubt that wisdom too.
Ugo
[1] :
function myflow() {
var obj = cocoon.getComponent(id);
obj.someMethodThrowingCheckedException();
// What? No cast? No try-catch? Where's the compiler??? ;-)
}
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Joerg Heinicke <jo...@gmx.de>.
Ugo Cei <u.cei <at> cbim.it> writes:
> > But the proposal cries IMHO for unforeseen
> > effects like not caught exceptions where they should have been caught.
>
> If all you do is log (maybe) and rethrow, this is a clear indication of
> the fact that the exception should NOT have been caught in the first place.
Agreed.
> > And for the specific case of ProcessingExceptions: Does not almost every of
> > our components have the ProcessingException in its throws clause? So where is
> > the need for catching/wrapping/rethrowing them?? Only current bad usage is
> > not a reason for changing it IMO.
>
> The compiler forces you to catch them.
Of course, but only exactly once at the end. How are the exceptions made
available to handle-errors at the moment? I guess somewhere in the tree
processor. So where is the problem letting it catch the exception? I still don't
see the need for the re-parenting.
Joerg
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <u....@cbim.it>.
Joerg Heinicke wrote:
> Ugo Cei <u.cei <at> cbim.it> writes:
>
>
>> catch (ProcessingException e) {
>> getLogger().*(*);
>> throw new *Exception(*, e);
>> }
>
>
> I'm not very experienced with designing Java class models and even less with
> checked vs. unchecked exceptions. But the proposal cries IMHO for unforeseen
> effects like not caught exceptions where they should have been caught.
If all you do is log (maybe) and rethrow, this is a clear indication of
the fact that the exception should NOT have been caught in the first place.
> And for the specific case of ProcessingExceptions: Does not almost every of our
> components have the ProcessingException in its throws clause? So where is the
> need for catching/wrapping/rethrowing them?? Only current bad usage is not a
> reason for changing it IMO.
The compiler forces you to catch them.
Ugo
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Joerg Heinicke <jo...@gmx.de>.
Ugo Cei <u.cei <at> cbim.it> writes:
> catch (ProcessingException e) {
> getLogger().*(*);
> throw new *Exception(*, e);
> }
I'm not very experienced with designing Java class models and even less with
checked vs. unchecked exceptions. But the proposal cries IMHO for unforeseen
effects like not caught exceptions where they should have been caught.
And for the specific case of ProcessingExceptions: Does not almost every of our
components have the ProcessingException in its throws clause? So where is the
need for catching/wrapping/rethrowing them?? Only current bad usage is not a
reason for changing it IMO.
Joerg
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <u....@cbim.it>.
Nicola Ken Barozzi wrote:
> Ugo Cei wrote:
>> For 2.2 (which we have agreed will require JDK 1.4 IIRC, so we can
>> count on exception chaining) I will propose to define a
>> Cocoon-specific hierarchy of exceptions, whose root is
>> java.lang.RuntimeException. And 3rd party exception classes like
>> SAXException will have to be wrapped inside Cocoon-specific runtime
>> exceptions.
> Gaaak! Why so? I just don't get it, you don't like wrapping but are
> going to do it nevertheless?
I'm going to wrap only if I'm forced to or it adds value, i.e.
information. Not just because I am forced by a "throws" clause in a
method signature.
If there's no "throws", I get to decide whether to wrap or not.
>> How about this?
>>
>> } catch (ProcessingException e) {
>> getLogger().debug("Rethrowing exception", e);
>> throw new SAXException(e);
>> }
>>
>> This is not only useless, it's plain wrong.
>
> First of all, why are you logging? Useless.
Me? This is not code I wrote, it's in our CVS.
I'm not into pshychic reading, but it seems to me quite evident that
whoever wrote that code was feeling somewhat helpless or even guilty: "I
don't know what to do with this ProcessingException that I'm *forced* to
catch by the compiler, so I'm going to log it to share the burden of my
guilt". But the author should not blame himself of feel guilty. He
should blame the fact that ProcessingException is checked.
Do you know what this is? This is a _code_ _smell_ and I want to remove it.
Obviously, you appreciate checked exceptions more than I do, and there's
nothing wrong with that. You are in Gosling's camp, and probably the
majority of programmers is with you. I'm not going to change your mind
and make you switch over to Eckel's camp in the space of a maling list
thread.
But let's be pragmatic. We have an *evident* code smell (I hope you at
least agree with me on this point) and want to remove it. My pragmatic
approach is: make ProcessingException extend CascadingRuntimeException,
find all the lines of code that match this template:
catch (ProcessingException e) {
getLogger().*(*);
throw new *Exception(*, e);
}
and simply remove them. *POOF* away goes the smell.
If you don't agree, then what is your proposal?
Ugo
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Nicola Ken Barozzi <ni...@apache.org>.
Ugo Cei wrote:
> Nicola Ken Barozzi wrote:
>
>> Ugo Cei wrote:
>>
>>> We have something worse than generic ProcessingExceptions being
>>> thrown, we have components throwing CascadingException. Which not
>>> only force clients to check them, but create an unnecessary
>>> dependence on Avalon.
>>
>> Whaich I agree with, but still it's not about checked VS unchecked.
>
> It's a different issue, yes. I mentioned it just because I noticed that
> it should be fixed while reparenting ProcessingException.
>
> It would be better if CascadingException were abstract, and
> ProcessingException too, so that throwers would be forced to reuse or
> define a more specific exception class, instead of being lazy.
>
> For 2.2 (which we have agreed will require JDK 1.4 IIRC, so we can count
> on exception chaining) I will propose to define a Cocoon-specific
> hierarchy of exceptions, whose root is java.lang.RuntimeException. And
> 3rd party exception classes like SAXException will have to be wrapped
> inside Cocoon-specific runtime exceptions.
Gaaak! Why so? I just don't get it, you don't like wrapping but are
going to do it nevertheless?
> This is the approach taken by Spring, and I know that many of you don't
> like it, but ideas change with time, and we will have plenty of time to
> discuss and change the minds of people. Even mine, maybe ;-).
>
>>> And I'm not going to throw out any baby. I'm going to throw out lots
>>> of totally useless "catch" clauses that do nothing but litter the code.
>>
>> You don't need to use unchecked exceptions to do that. I don't see the
>> connection.
>
> How about this?
>
> } catch (ProcessingException e) {
> getLogger().debug("Rethrowing exception", e);
> throw new SAXException(e);
> }
>
> This is not only useless, it's plain wrong.
First of all, why are you logging? Useless.
Second, why are you rethrowing the exception? There is a meaning to it.
try{
here the IO makes an error;
} catch (ProcessingException e) {
//a ProcessingException occurred.
//what can I do about it? should I retry?
//I was not able to process something, but
//now I have to honor my contract.
//Can I end the xml? Yes... so let's do it:
end.the.xml();
//I'm not throwing, as for SAX I'm ok, the SAX stream is ok
//throw new SAXException(e);
}
IOW, the fact that there is an exception mismatch between what I catch
and what I throw should make me think about what impact the caught
exception has on me and on the possibility or not of finishing the work.
If I cannot finish what I can do - and note that the exceptions I throw
define what my parent can or cannot fix - shall I eventually tell my parent.
If you use Runtime exceptions all this goes away and instead of
rethrowing you will see exceptions being gobbled up.
Not only we will have the opposite problem, ie not catching instead of
rethrowing everything, but we will be unable to go through the code
searching for rethrowing and asking ourselves if it's correct or not.
--
Nicola Ken Barozzi nicolaken@apache.org
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <u....@cbim.it>.
Nicola Ken Barozzi wrote:
> Ugo Cei wrote:
>> We have something worse than generic ProcessingExceptions being
>> thrown, we have components throwing CascadingException. Which not only
>> force clients to check them, but create an unnecessary dependence on
>> Avalon.
>
> Whaich I agree with, but still it's not about checked VS unchecked.
It's a different issue, yes. I mentioned it just because I noticed that
it should be fixed while reparenting ProcessingException.
It would be better if CascadingException were abstract, and
ProcessingException too, so that throwers would be forced to reuse or
define a more specific exception class, instead of being lazy.
For 2.2 (which we have agreed will require JDK 1.4 IIRC, so we can count
on exception chaining) I will propose to define a Cocoon-specific
hierarchy of exceptions, whose root is java.lang.RuntimeException. And
3rd party exception classes like SAXException will have to be wrapped
inside Cocoon-specific runtime exceptions.
This is the approach taken by Spring, and I know that many of you don't
like it, but ideas change with time, and we will have plenty of time to
discuss and change the minds of people. Even mine, maybe ;-).
>> And I'm not going to throw out any baby. I'm going to throw out lots
>> of totally useless "catch" clauses that do nothing but litter the code.
>
> You don't need to use unchecked exceptions to do that. I don't see the
> connection.
How about this?
} catch (ProcessingException e) {
getLogger().debug("Rethrowing exception", e);
throw new SAXException(e);
}
This is not only useless, it's plain wrong.
Ugo
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Nicola Ken Barozzi <ni...@apache.org>.
Ugo Cei wrote:
> Nicola Ken Barozzi wrote:
>
>> In any case (and note that this is a vote, not a veto) the main reason
>> is that in doing this we risk to throw out the baby with the water: I
>> prefer a lot to remove ProcessingExceptions comptely and have the
>> Cocoon components throw all the exceptions that the container can and
>> will handle. IOW, I don't want to have an implicit contract but a more
>> detailed and explicit one. In any case, generic ProcessingExceptions
>> are evil, and this is a fact that we have known for a long time.
>
> We have something worse than generic ProcessingExceptions being thrown,
> we have components throwing CascadingException. Which not only force
> clients to check them, but create an unnecessary dependence on Avalon.
Whaich I agree with, but still it's not about checked VS unchecked.
> And I'm not going to throw out any baby. I'm going to throw out lots of
> totally useless "catch" clauses that do nothing but litter the code.
You don't need to use unchecked exceptions to do that. I don't see the
connection.
--
Nicola Ken Barozzi nicolaken@apache.org
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <u....@cbim.it>.
Nicola Ken Barozzi wrote:
> In any case (and note that this is a vote, not a veto) the main reason
> is that in doing this we risk to throw out the baby with the water: I
> prefer a lot to remove ProcessingExceptions comptely and have the Cocoon
> components throw all the exceptions that the container can and will
> handle. IOW, I don't want to have an implicit contract but a more
> detailed and explicit one. In any case, generic ProcessingExceptions are
> evil, and this is a fact that we have known for a long time.
We have something worse than generic ProcessingExceptions being thrown,
we have components throwing CascadingException. Which not only force
clients to check them, but create an unnecessary dependence on Avalon.
And I'm not going to throw out any baby. I'm going to throw out lots of
totally useless "catch" clauses that do nothing but litter the code.
When we have done that, we'll have a cleaner baby, and we can send him
to school so that he can learn to behave himself properly. But this is
going to take time.
So, the options are: start small, remove useless code and do "continuous
design", like Berin advocated. Or discuss for months, come up with a
renewed exception hierarchy and take some more months to implement it.
As always, IMHO
Ugo
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Nicola Ken Barozzi <ni...@apache.org>.
Reinhard Pötz wrote:
> Nicola Ken Barozzi wrote:
>
>> Ugo Cei wrote:
>>
>>> I think everyone interested has had the option of venting his opinion
>>> on the subject of checked vs. unchecked exceptions. For the record,
>>> here [1] is the relevant thread.
>>>
>>> In order to move forward, I propose to reparent the
>>> org.apache.cocoon.ProcessingException to extend
>>> org.apache.avalon.framework.CascadingRuntimeException instead of
>>> CascadingException.
>>>
>>> The change is backward-compatible and is a one-line change that can
>>> be reverted easily, but might have implications on the way we manage
>>> exceptions in the future.
>>>
>>> I've already performed the change locally and everything compiles.
>>> Tests fail, but they failed also before the change :-(.
>>>
>>> So, please cast your votes.
>>
>>
>> -1
>
> Nicola, could you summarize the reasons for your -1?
> (... I haven't followed the previous discussion on exceptions very
> closely, so pls forgive if you already pointed out your concerns)
In the archives you can find my opinion.
In any case (and note that this is a vote, not a veto) the main reason
is that in doing this we risk to throw out the baby with the water: I
prefer a lot to remove ProcessingExceptions comptely and have the Cocoon
components throw all the exceptions that the container can and will
handle. IOW, I don't want to have an implicit contract but a more
detailed and explicit one. In any case, generic ProcessingExceptions are
evil, and this is a fact that we have known for a long time.
--
Nicola Ken Barozzi nicolaken@apache.org
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Marc Portier <mp...@outerthought.org>.
Reinhard Pötz wrote:
> Nicola Ken Barozzi wrote:
>
>> Ugo Cei wrote:
>>
>>> I think everyone interested has had the option of venting his opinion
>>> on the subject of checked vs. unchecked exceptions. For the record,
>>> here [1] is the relevant thread.
>>>
>>> In order to move forward, I propose to reparent the
>>> org.apache.cocoon.ProcessingException to extend
>>> org.apache.avalon.framework.CascadingRuntimeException instead of
>>> CascadingException.
>>>
>>> The change is backward-compatible and is a one-line change that can
>>> be reverted easily, but might have implications on the way we manage
>>> exceptions in the future.
>>>
>>> I've already performed the change locally and everything compiles.
>>> Tests fail, but they failed also before the change :-(.
>>>
>>> So, please cast your votes.
>>
>>
>>
>> -1
>>
>
> Nicola, could you summarize the reasons for your -1?
> (... I haven't followed the previous discussion on exceptions very
> closely, so pls forgive if you already pointed out your concerns)
>
Nicola can speak for himself I suppose...
however, reading his answer again in the previous thread:
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=108196560613519&w=2
...I find some recognisable motivation for my personal under-enthousiasm
on this topic
What I personally catched from the previous thread was (besides some
fond memories of C++) some tendency towards a more nuanced view saying
we should be cautious with checked exceptions and carefully decide when
and where to introduce them. (by considering both sides of the contract
that defines them?)
I grade my personal under-enthousiasm to the level of "indifference",
leading me to a neutral 0-vote: a free ticket to those that are
enthousiast :-)
For sure a set of more balanced considerations on the interfaces at hand
(rather then a generalizing reaction triggered by some modern
reactionary movement) would of have easily catched my enthousiasm...
regards,
-marc=
--
Marc Portier http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
Read my weblog at http://blogs.cocoondev.org/mpo/
mpo@outerthought.org mpo@apache.org
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Reinhard Pötz <re...@apache.org>.
Nicola Ken Barozzi wrote:
> Ugo Cei wrote:
>
>> I think everyone interested has had the option of venting his opinion
>> on the subject of checked vs. unchecked exceptions. For the record,
>> here [1] is the relevant thread.
>>
>> In order to move forward, I propose to reparent the
>> org.apache.cocoon.ProcessingException to extend
>> org.apache.avalon.framework.CascadingRuntimeException instead of
>> CascadingException.
>>
>> The change is backward-compatible and is a one-line change that can
>> be reverted easily, but might have implications on the way we manage
>> exceptions in the future.
>>
>> I've already performed the change locally and everything compiles.
>> Tests fail, but they failed also before the change :-(.
>>
>> So, please cast your votes.
>
>
> -1
>
Nicola, could you summarize the reasons for your -1?
(... I haven't followed the previous discussion on exceptions very
closely, so pls forgive if you already pointed out your concerns)
--
Reinhard
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Nicola Ken Barozzi <ni...@apache.org>.
Ugo Cei wrote:
> I think everyone interested has had the option of venting his opinion on
> the subject of checked vs. unchecked exceptions. For the record, here
> [1] is the relevant thread.
>
> In order to move forward, I propose to reparent the
> org.apache.cocoon.ProcessingException to extend
> org.apache.avalon.framework.CascadingRuntimeException instead of
> CascadingException.
>
> The change is backward-compatible and is a one-line change that can be
> reverted easily, but might have implications on the way we manage
> exceptions in the future.
>
> I've already performed the change locally and everything compiles. Tests
> fail, but they failed also before the change :-(.
>
> So, please cast your votes.
-1
--
Nicola Ken Barozzi nicolaken@apache.org
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
Re: [VOTE] Make ProcessingException extend CascadingRuntimeException
Posted by Ugo Cei <ug...@apache.org>.
Il giorno 16/apr/04, alle 00:02, Ugo Cei ha scritto:
> The change is backward-compatible and is a one-line change that can be
> reverted easily, but might have implications on the way we manage
> exceptions in the future.
Actually, we have a few cases of "catch(CascadingException)" here and
there, that should be examined and maybe fixed too.
Ugo
Re: [VOTE] Make ProcessingException extend
CascadingRuntimeException
Posted by Stephan Michels <st...@apache.org>.
Am Fr, den 16.04.2004 schrieb Ugo Cei um 0:02:
> In order to move forward, I propose to reparent the
> org.apache.cocoon.ProcessingException to extend
> org.apache.avalon.framework.CascadingRuntimeException instead of
> CascadingException.
> So, please cast your votes.
+1
Stephan.