LipmError.pm

Code Index:


#
#       sebastien.letort@toulouse.inra.fr
#       Created: september 18, 2007
#       Last Updated: september 18, 2007
#

package LipmError;


NAME

        LipmError - a class to interface Error classe developped in the lipm


SYNOPSIS

        It's an interface, it should not be instancied


DESCRIPTION

        This interface centralized what is common with all Error class developped in the lipm.
        It declare our global error code and some common methods.


SUBROUTINES

        GetMsg
        IsFatal
        Explain


AUTHOR

        Sebastien Letort : sebastien.letort@toulouse.inra.fr
use warnings;
use strict;

## this class inherit from Error.pm
use base qw(Error);

# constantes
use constant FATAL => 0001;

BEGIN
{
    our $VERSION = do {my @r = (q$Rev: 172 $ =~ /\d+/g); $r[0]};
}

Function IsFatal

        Title      :    IsFatal
        Usage      :    my $bool = $err->IsFatal()
        Prerequiste:    Fatal code are odd code value
        Function   :    tell if the program must stop
        Returns    :    a boolean, 1 if value is FATAL
        Args       :    none
        Error      :    none
        Globals    :    none
sub IsFatal
{
    my $self = shift;

    return ($self->{-value} & &FATAL);
}

Function GetMsg

        Title      :    GetMsg
        Usage      :    my $msg = $err->GetMsg()
        Prerequiste:    none
        Function   :    give a formatted msg containing where the error occurred
        Returns    :    a string
        Args       :    none
        Error      :    none
        Globals    :    none
sub GetMsg
{
    my $self = shift;

    # Construct message
    my $msg = ref($self) . " thrown by " . $self->{-file};
    $msg .= " on line " . $self->{-line} . "\n";

    return $msg;
}

Function Explain

        Title      :    Explain
        Usage      :    my $string = $err->Explain()
        Prerequiste:    pure virtual method, it have to be overwritten to be used
        Function   :    explain the error in details
        Returns    :    a string
        Args       :    none
        Error      :    none
        Globals    :    none
sub Explain { }

1;