Modules Index

XML Schema Home

# XML::Schema::Exception

This module implements an exception class for XML::Schema.

## Table of Contents

Synopsis |  |  |
Description |  |  |
Methods | : | new(), type(), info(), text() |

## Synopsis

    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;

## Description

This module implements a simple object for representing errors thrown by various XML::Schema modules.

## Methods

- new( $type, $info )

  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".

      print $e->text();   # '[parser] parse error at line 42'

  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;           # '[parser] parse error at line 42'

Perl XML::Schema Documentation