SILENT KILLERPanel

Current Path: > > usr > local > share > perl5 > XML > > SAX >


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //usr/local/share/perl5/XML//SAX/

NameTypeSizeLast ModifiedActions
PurePerl Directory - -
Base.pm File 122901 bytes April 03 2017 09:00:11.
BuildSAXBase.pl File 28687 bytes April 03 2017 09:00:11.
DocumentLocator.pm File 2882 bytes June 13 2019 23:18:28.
Exception.pm File 3033 bytes April 03 2017 09:00:11.
Expat.pm File 19653 bytes January 21 2014 01:42:34.
Intro.pod File 14817 bytes June 13 2019 23:24:14.
ParserDetails.ini File 380 bytes March 17 2024 10:36:19.
ParserFactory.pm File 6535 bytes June 14 2019 01:57:58.
PurePerl.pm File 20587 bytes June 14 2019 01:57:58.

Reading File: //usr/local/share/perl5/XML//SAX//Exception.pm

package XML::SAX::Exception;
$XML::SAX::Exception::VERSION = '1.09';
use strict;

use overload '""' => "stringify",
    'fallback' => 1;

use vars qw($StackTrace);

use Carp;

$StackTrace = $ENV{XML_DEBUG} || 0;

# Other exception classes:

@XML::SAX::Exception::NotRecognized::ISA = ('XML::SAX::Exception');
@XML::SAX::Exception::NotSupported::ISA = ('XML::SAX::Exception');
@XML::SAX::Exception::Parse::ISA = ('XML::SAX::Exception');


sub throw {
    my $class = shift;
    if (ref($class)) {
        die $class;
    }
    die $class->new(@_);
}

sub new {
    my $class = shift;
    my %opts = @_;
    confess "Invalid options: " . join(', ', keys %opts) unless exists $opts{Message};
    
    bless { ($StackTrace ? (StackTrace => stacktrace()) : ()), %opts },
        $class;
}

sub stringify {
    my $self = shift;
    local $^W;
    my $error;
    if (exists $self->{LineNumber}) {
        $error = $self->{Message} . " [Ln: " . $self->{LineNumber} . 
                ", Col: " . $self->{ColumnNumber} . "]";
    }
    else {
        $error = $self->{Message};
    }
    if ($StackTrace) {
        $error .= stackstring($self->{StackTrace});
    }
    $error .= "\n";
    return $error;
}

sub stacktrace {
    my $i = 2;
    my @fulltrace;
    while (my @trace = caller($i++)) {
        my %hash;
        @hash{qw(Package Filename Line)} = @trace[0..2];
        push @fulltrace, \%hash;
    }
    return \@fulltrace;
}

sub stackstring {
    my $stacktrace = shift;
    my $string = "\nFrom:\n";
    foreach my $current (@$stacktrace) {
        $string .= $current->{Filename} . " Line: " . $current->{Line} . "\n";
    }
    return $string;
}

1;

__END__

=head1 NAME

XML::SAX::Exception - Exception classes for XML::SAX

=head1 SYNOPSIS

  throw XML::SAX::Exception::NotSupported(
          Message => "The foo feature is not supported",
          );

=head1 DESCRIPTION

This module is the base class for all SAX Exceptions, those defined in
the spec as well as those that one may create for one's own SAX errors.

There are three subclasses included, corresponding to those of the SAX
spec:

  XML::SAX::Exception::NotSupported
  XML::SAX::Exception::NotRecognized
  XML::SAX::Exception::Parse

Use them wherever you want, and as much as possible when you encounter
such errors. SAX is meant to use exceptions as much as possible to 
flag problems.

=head1 CREATING NEW EXCEPTION CLASSES

All you need to do to create a new exception class is:

  @XML::SAX::Exception::MyException::ISA = ('XML::SAX::Exception')

The given package doesn't need to exist, it'll behave correctly this 
way. If your exception refines an existing exception class, then you
may also inherit from that instead of from the base class.

=head1 THROWING EXCEPTIONS

This is as simple as exemplified in the SYNOPSIS. In fact, there's 
nothing more to know. All you have to do is:

  throw XML::SAX::Exception::MyException( Message => 'Something went wrong' );

and voila, you've thrown an exception which can be caught in an eval block.

=cut


SILENT KILLER Tool