MKDoc::Core::Error - Object validation error mechanism.


When building web apps errors have to be handled in a certain way. It is not possible to rely on Javascript, and die() unless it's eval triggers a 500 internal server error, which is a tad brutal.

This class provides a mechanism for web error reporting. When validating a data object, the object can create one or more MKDoc::Core::Error objects. Those object are then caught by a callback subroutine which is set by MKDoc::Core::Plugin objects and then stored as an array reference within MKDoc::Core::Plugin object themselves.

This allows the template to access the error array to do proper user error reporting in the event where there would be user input errors which prevent certain objects from validating.

When a user is editing some kind of object, it is needed to report all the errors which the user has made. Usually, objects implement a validate() method as follows:

  sub validate
      my $self = shift;
      return $self->_validate_XXX() &
             $self->_validate_XXY() &

With each _validate_XXX() method looking like this:

  sub _validate_silly_check
      my $self = shift;
      $time % 0 && return 1;

      new MKDoc::Core::Error ( 'time_is_odd' ) :
      return 0;


Copyright 2003 - MKDoc Holdings Ltd.

Author: Jean-Michel Hiver

This module is free software and is distributed under the same license as Perl itself. Use it at your own risk.


  L<Petal> TAL for perl

Help us open-source MKDoc. Join the mkdoc-modules mailing list: