GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Rose::HTML::Object::Errors(3) User Contributed Perl Documentation Rose::HTML::Object::Errors(3)

Rose::HTML::Object::Errors - Error ids and named constants for use with HTML objects.

  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;

Rose::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.

  • Error ids from 0 to 29,999 are reserved for built-in errors.
  • Negative error ids are reserved for internal use.

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.

Rose::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.

The 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

add_error NAME, ID
Add a new error constant with NAME and an integer ID value. 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. Constant names may contain only the characters "[A-Z0-9_]" and must be unique among all error names.
add_errors [NAME1, NAME2, ...]
If called with no arguments, this method adds all error constants defined in the calling class. Example:

    __PACKAGE__->add_errors;
    

If called with a list of constant names, add each named constant to the list of errors. These constants must already exist in the calling class. Example:

    use constant MY_ERROR1 => 123456;
    use constant MY_ERROR2 => 123457;
    ...
    __PACKAGE__->add_errors('MY_ERROR1', 'MY_ERROR2');
    
get_error_id NAME
Returns the integer error id corresponding to the symbolic constant NAME, or undef if no such name exists.
get_error_name ID
Returns the symbolic error constant name corresponding to the integer error ID, or undef if no such error ID exists.
error_id_exists ID
Return true of the integer error ID exists, false otherwise.
error_name_exists NAME
Return true of the symbolic error constant NAME exists, false otherwise.
error_ids
Returns a list (in list context) or reference to an array (in scalar context) of integer error ids.
error_names
Returns a list (in list context) or reference to an array (in scalar context) of error names.

John C. Siracusa (siracusa@gmail.com)

Copyright (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.
2015-03-17 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.