{
    "mode": "perldoc",
    "parameter": "Class::ErrorHandler",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Class%3A%3AErrorHandler/json",
    "generated": "2026-06-15T13:37:36Z",
    "synopsis": "package Foo;\nuse base qw( Class::ErrorHandler );\nsub classmethod {\nmy $class = shift;\n...\nreturn $class->error(\"Help!\")\nunless $continue;\n}\nsub objectmethod {\nmy $obj = shift;\n...\nreturn $obj->error(\"I am no more\")\nunless $continue;\n}\npackage main;\nuse Foo;\nFoo->classmethod or die Foo->errstr;\nmy $foo = Foo->new;\n$foo->objectmethod or die $foo->errstr;",
    "sections": {
        "NAME": {
            "content": "Class::ErrorHandler - Base class for error handling\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "package Foo;\nuse base qw( Class::ErrorHandler );\n\nsub classmethod {\nmy $class = shift;\n...\nreturn $class->error(\"Help!\")\nunless $continue;\n}\n\nsub objectmethod {\nmy $obj = shift;\n...\nreturn $obj->error(\"I am no more\")\nunless $continue;\n}\n\npackage main;\nuse Foo;\n\nFoo->classmethod or die Foo->errstr;\n\nmy $foo = Foo->new;\n$foo->objectmethod or die $foo->errstr;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "*Class::ErrorHandler* provides an error-handling mechanism that's generic enough to be used as\nthe base class for a variety of OO classes. Subclasses inherit its two error-handling methods,\n*error* and *errstr*, to communicate error messages back to the calling program.\n\nOn failure (for whatever reason), a subclass should call *error* and return to the caller;\n*error* itself sets the error message internally, then returns \"undef\". This has the effect of\nthe method that failed returning \"undef\" to the caller. The caller should check for errors by\nchecking for a return value of \"undef\", and calling *errstr* to get the value of the error\nmessage on an error.\n\nAs demonstrated in the SYNOPSIS, *error* and *errstr* work as both class methods and object\nmethods.\n",
            "subsections": []
        },
        "USAGE": {
            "content": "Class->error($message)\n$object->error($message)\nSets the error message for either the class *Class* or the object *$object* to the message\n*$message*. Returns \"undef\".\n\nClass->errstr\n$object->errstr\nAccesses the last error message set in the class *Class* or the object *$object*, respectively,\nand returns that error message.\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "This library is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n\nAUTHOR & COPYRIGHT\nExcept where otherwise noted, *Class::ErrorHandler* is Copyright 2004 Benjamin Trott,\ncpan@stupidfool.org. All rights reserved.\n",
            "subsections": []
        }
    },
    "summary": "Class::ErrorHandler - Base class for error handling",
    "flags": [],
    "examples": [],
    "see_also": []
}