|
NAMERose::HTML::Object::Errors - Error ids and named constants for use with HTML objects. SYNOPSIS package My::HTML::Object::Errors;
use strict;
# Import the standard set of error ids
use Rose::HTML::Object::Errors qw(:all);
use base qw(Rose::HTML::Object::Errors);
##
## Define your new error ids below
##
# Error ids from 0 to 29,999 are reserved for built-in errors.
# Negative error ids are reserved for internal use. Please use error
# ids 30,000 or higher for your errors. Suggested error id ranges
# and naming conventions for various error types are shown below.
# Field errors
use constant FIELD_ERROR_PASSWORD_TOO_SHORT => 101_000;
use constant FIELD_ERROR_USERNAME_INVALID => 101_001;
...
# Generic errors
use constant LOGIN_NO_SUCH_USER => 200_000;
use constant LOGIN_USER_EXISTS_ERROR => 200_001;
...
# This line must be below all the "use constant ..." declarations
BEGIN { __PACKAGE__->add_errors }
1;
DESCRIPTIONRose::HTML::Object::Errors stores error ids and names. The error ids are defined as Perl constants with integer values. The constants themselves as well as the mapping between the symbolic constant names and their values are stored as class data. If you merely want to import one of the standard error id constants, you may use this module as-is (see the EXPORTS section for details). If you want to define your own errors, you must subclass this module exactly as shown in the synopsis. The order of the statements is important! When adding your own errors, you are free to choose any integer error id values, subject to the following constraints.
Please use ids 30,000 or higher for your errors. Constant names may contain only the characters "[A-Z0-9_]" and must be unique among all error constant names. EXPORTSRose::HTML::Object::Errors does not export any symbols by default. The 'all' tag: use Rose::HTML::Object::Errors qw(:all); will cause all error name constant to be imported. The following tags will cause all errors whose names match the regular expression to the right of the tag name to be imported. TAG NAME REGEX
----- ----------
field ^FIELD_
form ^FORM_
date ^DATE_
time ^TIME_
email ^EMAIL_
phone ^PHONE_
number ^NUM_
set ^SET_
string ^STRING_
For example, this will import all the error constants whose names begin with "FIELD_" use Rose::HTML::Object::Errors qw(:field); Finally, you can import individual error constant names as well: use Rose::HTML::Object::Errors qw(FIELD_REQUIRED NUM_INVALID_INTEGER); A complete listing of the default set of error constant names appears in the next section. BUILT-IN ERRORSThe list of built-in errors appears below. You should not rely on the actual numeric values of these constants. Import and refer to them only by their symbolic names. FIELD_REQUIRED
FIELD_PARTIAL_VALUE
FIELD_INVALID
FORM_HAS_ERRORS
NUM_INVALID_INTEGER
NUM_INVALID_INTEGER_POSITIVE
NUM_NOT_POSITIVE_INTEGER
NUM_BELOW_MIN
NUM_ABOVE_MAX
NUM_INVALID_NUMBER
NUM_INVALID_NUMBER_POSITIVE
NUM_NOT_POSITIVE_NUMBER
STRING_OVERFLOW
DATE_INVALID
DATE_MIN_GREATER_THAN_MAX
TIME_INVALID
TIME_INVALID_HOUR
TIME_INVALID_MINUTE
TIME_INVALID_SECONDS
TIME_INVALID_AMPM
EMAIL_INVALID
PHONE_INVALID
SET_INVALID_QUOTED_STRING
SET_PARSE_ERROR
CLASS METHODS
AUTHORJohn C. Siracusa (siracusa@gmail.com) LICENSECopyright (c) 2010 by John C. Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|