![]() |
![]() |
use XML::Schema::Exception; my $err = XML::Schema::Exception->new('type_x', 'info_y'); print $err->type(); # type_x print $err->info(); # info_y print $err->text(); # [type_x] info_y print $err; # [type_x] info_y die $err;
This module implements a simple object for representing errors thrown by various XML::Schema modules.
Constructor method called to create a new exception object. The first argument should be a simple string to identifying the exception type. The second can be a string containing further information or a reference to any other data type.
die XML::Schema::Exception->new( parser => 'parse error at line 42' );
type()
Returns the exception type.
my $e = XML::Schema::Exception->new( parser => 'parse error at line 42' ); print $e->type(); # 'parser'
info()
Returns the value of the additional information field.
print $e->info(); # 'parse error at line 42'
text()
Returns a text string of the form "[$type] $info".
This method is overloaded to the stringifiation operator. In other words, printing an exception object will generate the output returned from this method.print $e->text(); # '[parser] parse error at line 42'
print $e; # '[parser] parse error at line 42'