Pangloss::Term::Error - errors specific to Terms.


Pangloss documentation Contained in the Pangloss distribution.

Index


Code Index:

NAME

Top

Pangloss::Term::Error - errors specific to Terms.

SYNOPSIS

Top

  use Pangloss::Term::Error;
  use Pangloss::StoredObject::Error;

  throw Pangloss::Term::Error(flag => eExists, term => $term);
  throw Pangloss::Term::Error(flag => eNonExistent, name => $name);
  throw Pangloss::Term::Error(flag => eInvalid, term => $term,
                              invalid => {eTermNameRequired => 1});

  # with caught errors:
  print $e->term->name;

DESCRIPTION

Top

Term Errors class. Inherits interface from Pangloss::StoredObject::Error. May contain a term object associated with the error.

EXPORTED FLAGS

Top

Validation errors: eStatusRequired eConceptRequired eLanguageRequired

METHODS

Top

$e->term

set/get Pangloss::Term for this error.

$bool = $e->isStatusRequired, $e->isConceptRequired, $e->isLanguageRequired

Test if this error's flag is equal to the named flag.

AUTHOR

Top

Steve Purkis <spurkis@quiup.com>

SEE ALSO

Top

Error, Pangloss::StoredObject::Error, Pangloss::Term, Pangloss::Terms


Pangloss documentation Contained in the Pangloss distribution.
package Pangloss::Term::Error;

use strict;
use warnings::register;

use Pangloss::Term;

use base      qw( Exporter Pangloss::StoredObject::Error );
use accessors qw( term );

our $VERSION  = ((require Pangloss::Version), $Pangloss::VERSION)[1];
our $REVISION = (split(/ /, ' $Revision: 1.9 $ '))[2];
our @EXPORT   = qw( eStatusRequired eConceptRequired
		    eLanguageRequired );

use constant eStatusRequired   => 'term_status_required';
use constant eConceptRequired  => 'term_concept_required';
use constant eLanguageRequired => 'term_language_required';

sub new {
    my $class = shift;
    my %args  = @_;
    local $Error::Depth = $Error::Depth + 1;
    if (my $name = delete $args{name}) {
	$args{term} = new Pangloss::Term()->name($name);
    }
    $class->SUPER::new(map { /^term$/ ? '-term' : $_; } %args);
}

sub isStatusRequired {
    return shift->is(eStatusRequired);
}

sub isConceptRequired {
    return shift->is(eConceptRequired);
}

sub isLanguageRequired {
    return shift->is(eLanguageRequired);
}

sub stringify {
    my $self = shift;
    my $str  = $self->SUPER::stringify . ':term';
    $str    .= '=' . $self->term->key if $self->term;
    return $str;
}

1;

__END__

#------------------------------------------------------------------------------