John Drago

NAME

ASP4::ErrorHandler - Default fatal error handler

SYNOPSIS

In your asp4-config.json:

  ...
    "errors": {
      "error_handler":    "ASP4::ErrorHandler",
      "mail_errors_to":   "you@server.com",
      "mail_errors_from": "root@localhost",
      "smtp_server":      "localhost"
    },
  ...

DESCRIPTION

This class provides a default error handler which does the following:

1) Makes a simple HTML page and prints it to the browser, telling the user that an error has just occurred.

2) Sends that same HTML to the email address specified in the config, using the SMTP server also specified in the config. The email subject will look something like:

  ASP4: Error in your-site.com/index.asp

SUBCLASSING

To subclass ASP4::ErrorHandler you must do the following:

  package My::ErrorHandler;
  
  use strict;
  use warnings 'all';
  use base 'ASP4::ErrorHandler';
  use vars __PACKAGE__->VARS;
  
  sub run {
    my ($s, $context) = @_;
    
    my $error = $Stash->{error};
    
    # $error is an ASP4::Error object.
  
    # Do something here about the error.
    $s->print_error( $error );
    $s->send_error( $error );
  }
  
  1;# return true:

METHODS

error_html( $error )

Returns a string of html suitable for printing to the browser or emailing.

Prints the error html to the browser.

send_error( $error )

Sends the error html to the email address specified in the config, using <$Server-Mail(...)>> and the smtp server specified in the config.

BUGS

It's possible that some bugs have found their way into this release.

Use RT http://rt.cpan.org/NoAuth/Bugs.html?Dist=ASP4 to submit bug reports.

HOMEPAGE

Please visit the ASP4 homepage at http://0x31337.org/code/ to see examples of ASP4 in action.

AUTHOR

John Drago <jdrago_999@yahoo.com>

COPYRIGHT

Copyright 2008 John Drago. All rights reserved.

LICENSE

This software is Free software and is licensed under the same terms as perl itself.