| 1 | # -*- Mode: perl -*- | ||
| 2 | # | ||
| 3 | # $Id: Error.pm,v 0.1 2001/04/22 17:57:03 ram Exp $ | ||
| 4 | # | ||
| 5 | # Copyright (c) 1998-2001, Raphael Manfredi | ||
| 6 | # Copyright (c) 2000-2001, Christophe Dehaudt | ||
| 7 | # | ||
| 8 | # You may redistribute only under the terms of the Artistic License, | ||
| 9 | # as specified in the README file that comes with the distribution. | ||
| 10 | # | ||
| 11 | # HISTORY | ||
| 12 | # $Log: Error.pm,v $ | ||
| 13 | # Revision 0.1 2001/04/22 17:57:03 ram | ||
| 14 | # Baseline for first Alpha release. | ||
| 15 | # | ||
| 16 | # $EndLog$ | ||
| 17 | # | ||
| 18 | |||
| 19 | use strict; | ||
| 20 | |||
| 21 | package CGI::MxScreen::Error; | ||
| 22 | |||
| 23 | require Exporter; | ||
| 24 | |||
| 25 | use vars qw(@ISA @EXPORT @EXPORT_OK); | ||
| 26 | @ISA = qw(Exporter); | ||
| 27 | |||
| 28 | my @ERRORS = qw( | ||
| 29 | CGI_MX_OK | ||
| 30 | CGI_MX_ABORT | ||
| 31 | CGI_MX_ERROR | ||
| 32 | ); | ||
| 33 | |||
| 34 | @EXPORT = @ERRORS; | ||
| 35 | @EXPORT_OK = qw(is_mx_errcode); | ||
| 36 | |||
| 37 | # | ||
| 38 | # Errors have weird values, on purpose, so that constants are used. | ||
| 39 | # | ||
| 40 | |||
| 41 | use constant CGI_MX_OK => 3; # OK | ||
| 42 | use constant CGI_MX_ERROR => 8; # Error detected, can run other cbacks | ||
| 43 | use constant CGI_MX_ABORT => 17; # Abort processing, no more cback | ||
| 44 | |||
| 45 | my %ERRORS; | ||
| 46 | { | ||
| 47 | no strict 'refs'; | ||
| 48 | %ERRORS = map { &{$_}() => undef } @ERRORS; | ||
| 49 | } | ||
| 50 | |||
| 51 | # | ||
| 52 | # is_mx_errcode | ||
| 53 | # | ||
| 54 | # Check whether value is a valid CGI_MX_* error code. | ||
| 55 | # | ||
| 56 | sub is_mx_errcode { | ||
| 57 | my ($err) = @_; | ||
| 58 | return exists $ERRORS{$err} ? 1 : 0; | ||
| 59 | } | ||
| 60 | |||
| 61 | 1; | ||
| 62 | |||
| 63 | =head1 NAME | ||
| 64 | |||
| 65 | CGI::MxScreen::Error - Error return codes for action callbacks | ||
| 66 | |||
| 67 | =head1 SYNOPSIS | ||
| 68 | |||
| 69 | use CGI::MxScreen::Error; | ||
| 70 | |||
| 71 | sub action { # action callback | ||
| 72 | ... | ||
| 73 | return CGI_MX_ABORT; # for instance | ||
| 74 | } | ||
| 75 | |||
| 76 | =head1 DESCRIPTION | ||
| 77 | |||
| 78 | This module exports the return codes to use in action callbacks: | ||
| 79 | |||
| 80 | =over 4 | ||
| 81 | |||
| 82 | =item C<CGI_MX_OK> | ||
| 83 | |||
| 84 | Signals everything went fine. | ||
| 85 | |||
| 86 | =item C<CGI_MX_ABORT> | ||
| 87 | |||
| 88 | An error was detected, and the action callback chain should be immediately | ||
| 89 | exited. No further callbacks will be invoked. | ||
| 90 | |||
| 91 | =item C<CGI_MX_ERROR> | ||
| 92 | |||
| 93 | An error was detected, but further action callbacks may still execute. | ||
| 94 | The error condition is remembered and will be raised at the end of the | ||
| 95 | callback chain. | ||
| 96 | |||
| 97 | =back | ||
| 98 | |||
| 99 | =head1 AUTHORS | ||
| 100 | |||
| 101 | The original authors are | ||
| 102 | Raphael Manfredi F<E<lt>Raphael_Manfredi@pobox.comE<gt>> | ||
| 103 | and | ||
| 104 | Christophe Dehaudt F<E<lt>Christophe.Dehaudt@teamlog.frE<gt>>. | ||
| 105 | |||
| 106 | Send bug reports, suggestions, problems or questions to | ||
| 107 | Jason Purdy F<E<lt>Jason@Purdy.INFOE<gt>> | ||
| 108 | |||
| 109 | =head1 SEE ALSO | ||
| 110 | |||
| 111 | CGI::MxScreen::Form::Button(3). | ||
| 112 | |||
| 113 | =cut | ||
| 114 |