Skip Menu |

This queue is for tickets about the XML-Validator-Schema CPAN distribution.

Report information
The Basics
Id: 23284
Status: open
Priority: 0/
Queue: XML-Validator-Schema

People
Owner: Nobody in particular
Requestors: rbdavison [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.08
Fixed in: (no value)



Subject: Validation "die"s if there is a problem
When I try to validate a XML document against a schema. If the validation failes the program dies. This shouldn't happen it should return undef so that programs that use the validator can continue and report errors to the user via their own means.
The behavior described is not a bug, that's how the module is designed to operate. If you want to catch the die() do your program doesn't exit use eval: eval { $parser->parse_uri('foo.xml') };
The behavior described is not a bug, that's how the module is designed to operate. If you want to catch the die() do your program doesn't exit use eval (adapted from the documentation): eval { $parser->parse_uri('foo.xml') }; print "Error occurred, but I don't care!\n" if $@; -sam
Subject: Re: [rt.cpan.org #23284] Validation "die"s if there is a problem
Date: Wed, 15 Nov 2006 18:05:51 +1100
To: bug-XML-Validator-Schema [...] rt.cpan.org
From: R Bernard Davison <rbdavison [...] cpan.org>
Thanks for the tip of using eval to catch the die. Personally I think that dieing is a bad thing. I'd much prefer to use something like this... unless ($parser->parse_uri('foo.xml')) { print "Error: Somethings not quite right. An error should have be provided.\n"; } ... But as you say there is another way to do it. Thanks, Bernie. On 15/11/2006, at 2:32 PM, via RT wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=23284 > > > The behavior described is not a bug, that's how the module is designed > to operate. If you want to catch the die() do your program doesn't > exit > use eval (adapted from the documentation): > > eval { $parser->parse_uri('foo.xml') }; > print "Error occurred, but I don't care!\n" if $@; > > -sam >
Subject: Re: [rt.cpan.org #23284] Validation "die"s if there is a problem
Date: Wed, 15 Nov 2006 00:02:15 -0800 (PST)
To: R Bernard Davison via RT <bug-XML-Validator-Schema [...] rt.cpan.org>
From: Sam Tregar <sam [...] tregar.com>
On Wed, 15 Nov 2006, R Bernard Davison via RT wrote: Show quoted text
> I'd much prefer to use something like this... > > unless ($parser->parse_uri('foo.xml')) > { > print "Error: Somethings not quite right. An error should have be > provided.\n"; > } > ...
It's really not too hard to do: eval { $parser->parse_uri('foo.xml') }; if ($@) { } And as a bonus, $@ contains a description of what went wrong! If you use XML::Filter::ExceptionLocator it will even contain line and column numbers for the error. Give exceptions a try - they take getting used to, but the extra flexibility they provide is worth it. Consider that you could catch that error at any level of your application. Doing something similar with error returns is a total nightmare. -sam