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