You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Mark Struberg <st...@yahoo.de> on 2011/01/17 09:10:41 UTC

MavenXpp3Reader question for maven-release-manager

Hi!

I have a quick question on MavenXpp3Reader#read()

It throws the checked IOException and XmlPullParserException, but can it also throw unchecked Exceptions under 'normal' conditions?

The code I need this for is PomFinder#findMatchingPom and PomFinder#parsePom. I like to make sure that it doesn't throw Exceptions on just parsing an 'invalid' pom. 

This is a perfectly legal scenario if you e.g. try to release a project with ITs or other scenarios where pom.xml files are present in a non-valid form in the SCM (because they e.g. get dynamically constructed, testing pom parsing, etc). 

So I'm not sure if I should add a catch (Exception e) instead of the 2 checked exceptions, or if all sane cases are already wrapped in XmlPullParserException.

Any advice?

txs and LieGrue,
strub


      

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


Re: MavenXpp3Reader question for maven-release-manager

Posted by Mark Struberg <st...@yahoo.de>.
I actually catch both XmlPullParserException and IOEsception already.

I'm not sure if catching too much (= general Exception) is good, but one can argue that any hardcore problem (disk errors, etc) would hit the build shortly after anyway. 

So I'll better move to Exception.

txs and LieGrue,
strub

--- On Mon, 1/17/11, Benjamin Bentmann <be...@udo.edu> wrote:

> From: Benjamin Bentmann <be...@udo.edu>
> Subject: Re: MavenXpp3Reader question for maven-release-manager
> To: "Maven Developers List" <de...@maven.apache.org>
> Date: Monday, January 17, 2011, 11:35 AM
> Mark Struberg wrote:
> 
> > It throws the checked IOException and
> XmlPullParserException, but can it also throw unchecked
> Exceptions under 'normal' conditions?
> 
> AFAIK no.
> 
> > So I'm not sure if I should add a catch (Exception e)
> instead of the 2 checked exceptions, or if all sane cases
> are already wrapped in XmlPullParserException.
> 
> Handling just XmlPullParserException is not enough as
> IOException can also occur. So the generic catch (Exception)
> should fit your needs I think.
> 
> 
> Benjamin
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
> 
> 


      

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


Re: MavenXpp3Reader question for maven-release-manager

Posted by Benjamin Bentmann <be...@udo.edu>.
Mark Struberg wrote:

> It throws the checked IOException and XmlPullParserException, but can it also throw unchecked Exceptions under 'normal' conditions?

AFAIK no.

> So I'm not sure if I should add a catch (Exception e) instead of the 2 checked exceptions, or if all sane cases are already wrapped in XmlPullParserException.

Handling just XmlPullParserException is not enough as IOException can 
also occur. So the generic catch (Exception) should fit your needs I think.


Benjamin

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