Remove trailing spaces, add a missing parenthesis, add 'otherwise' to the list of exported keywords, support 'ne' operator on exception objects.

This commit is contained in:
ian%hixie.ch 2002-12-26 03:11:34 +00:00
Родитель d54b3e292e
Коммит 0ee3e91c0f
1 изменённых файлов: 18 добавлений и 6 удалений

Просмотреть файл

@ -29,10 +29,10 @@
package PLIF::Exception;
use strict;
use vars qw(@ISA @EXPORT);
use overload '""' => 'stringify';
use overload '""' => 'stringify', 'cmp' => 'comparison';
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(try raise handle with unhandled except finally);
@EXPORT = qw(try raise handle with unhandled except otherwise finally);
# To use this package, you first have to define your own exceptions:
#
@ -206,13 +206,22 @@ sub unhandled() {
sub stringify {
my $self = shift;
if (defined($self->{'message'}) {
if (defined($self->{'message'})) {
return "$self->{'message'} at $self->{'filename'} line $self->{'line'}";
} else {
return ref($self) . " exception at $self->{'filename'} line $self->{'line'}";
}
}
sub comparison {
my($a, $b, $reverse) = @_;
my $result = ((defined($a) and defined($b)) ? ("$a" cmp "$b") :
defined($a) ? 1 :
defined($b) ? -1 :
0);
return $reverse ? !$result : $result;
}
package PLIF::Exception::Internal::Continuation;
@ -342,3 +351,6 @@ sub DESTROY {
return $self->SUPER::DESTROY(@_) if $self->{'resolved'};
warn "Incorrectly used \"unhandled\" function at $self->{'filename'} line $self->{'line'}\n"; # XXX can't raise an exception in a destructor
}
package PLIF::Exception::Alarm; use vars qw(@ISA); @ISA = qw(PLIF::Exception);