| Pangloss documentation | Contained in the Pangloss distribution. |
Pangloss::StoredObject::Error - base class for stored object errors.
# abstract - cannot be used directly
package SomeError;
use base qw( Pangloss::StoredObject::Error );
throw SomeError( flag => eExists, ... );
throw SomeError( flag => eNonExistent, ... );
throw SomeError( flag => eInvalid, invalid => { ... });
# with caught errors:
print $e->flag;
do { ... } if $e->isExists;
do { ... } if $e->isNonexistent;
do { ... } if $e->isInvalid;
Stored Object Errors class. Inherits interface from Pangloss::Error. Introduces validation error flags.
Error flags: eExists eInvalid eNonExistent
Validation errors: eNameRequired eCreatorRequired eDateRequired
set/get hash of validation error flags.
Test if this error's flag is equal to $flag. if this is a validation error also checks in the $e->invalid hash for $flag.
Test if this error's flag is equal to the named flag.
Refactor some of this out to OpenFrame::WebApp.
Write name(), date(), and creator() shortcuts to see if flag is associated with the given instance variable.
Steve Purkis <spurkis@quiup.com>
| Pangloss documentation | Contained in the Pangloss distribution. |
package Pangloss::StoredObject::Error; use strict; use warnings::register; use base qw( Exporter Pangloss::Error ); use accessors qw( invalid ); our $VERSION = ((require Pangloss::Version), $Pangloss::VERSION)[1]; our $REVISION = (split(/ /, ' $Revision: 1.6 $ '))[2]; our @EXPORT = qw( eExists eInvalid eNonExistent eNameRequired eCreatorRequired eDateRequired ); use constant eExists => 'object_exists'; use constant eInvalid => 'object_invalid'; use constant eNonExistent => 'object_non_existent'; use constant eNameRequired => 'object_name_required'; use constant eCreatorRequired => 'object_creator_required'; use constant eDateRequired => 'object_date_required'; sub new { my $class = shift; local $Error::Depth = $Error::Depth + 1; my $self = $class->SUPER::new(map { /^invalid$/ ? '-invalid' : $_; } @_); $self->invalid({}) unless $self->invalid; return $self; } sub is { my $self = shift; my $test = shift; return 1 if ($self->flag eq $test); return 1 if (($test ne eInvalid) and $self->isInvalid and $self->invalid->{$test}); return 0; } sub isInvalid { return shift->is(eInvalid); } sub isExists { return shift->is(eExists); } sub isNonExistent { return shift->is(eNonExistent); } sub isNameRequired { return shift->is(eNameRequired); } sub isCreatorRequired { return shift->is(eCreatorRequired); } sub isDateRequired { return shift->is(eDateRequired); } 1; __END__ #------------------------------------------------------------------------------