# info > CGI::Session::ErrorHandler

---
type: CommandReference
command: CGI::Session::ErrorHandler
mode: perldoc
section: 3pm
source: perldoc
---

## Quick Reference
- `require CGI::Session::ErrorHandler; @ISA = qw( CGI::Session::ErrorHandler );` — inherit error handling
- `$self->set_error("message")` — sets the error; always returns `undef`
- `$self->errstr` — retrieves the last error message

## Name
CGI::Session::ErrorHandler — error handling routines for [CGI::Session](https://www.chedong.com/phpMan.php/perldoc/CGI%3A%3ASession/markdown)

## Synopsis
perl
require CGI::Session::ErrorHandler;
@ISA = qw( CGI::Session::ErrorHandler );

# In a method:
sub some_method {
    my $self = shift;
    unless ( $some_condition ) {
        return $self->set_error("some_method(): \$some_condition isn't met");
    }
}
## Methods
- `set_error($message)` — sets the package variable `$errstr` to `$message` and returns `undef`. Implicitly creates `$pkg_name::errstr`.
- `errstr()` — returns the value last passed to `set_error()`. If never set, returns an empty string (safe for concatenation).

## Licensing
For support and licensing see [CGI::Session](https://www.chedong.com/phpMan.php/perldoc/CGI%3A%3ASession/markdown).