File:  [LON-CAPA] / loncom / interface / lonerrorhandler.pm
Revision 1.8: download - view: text, annotated - select for diffs
Fri Jul 8 21:21:56 2005 UTC (18 years, 10 months ago) by www
Branches: MAIN
CVS tags: version_2_1_X, version_2_1_3, version_2_1_2, version_2_1_1, version_2_1_0, version_2_0_X, version_2_0_99_1, version_2_0_2, version_2_0_1, version_2_0_0, version_1_99_3, version_1_99_2, HEAD
Bug #3256: don't rely on client.
Server probably save enough, bugs tend to be more localized than initially
assumed.

    1: # The LearningOnline Network
    2: # Internal Server Error Handler
    3: #
    4: # $Id: lonerrorhandler.pm,v 1.8 2005/07/08 21:21:56 www Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: 
   29: package Apache::lonerrorhandler;
   30: 
   31: use strict;
   32: use Apache::Constants qw(:common);
   33: use Apache::loncommon;
   34: use Apache::lonnet;
   35: use Apache::lonmsg;
   36: 
   37: sub handler {
   38:     my $r = shift;
   39:     &Apache::loncommon::content_type($r,'text/html');
   40:     $r->send_http_header;
   41:     return OK if $r->header_only;
   42: 
   43:     &Apache::loncommon::get_posted_cgi($r);
   44: 
   45:     my $html=&Apache::lonxml::xmlbegin();
   46:     my $bodytag=&Apache::loncommon::bodytag($env{'form.sendinfo'}?'Sending Error Report':'Could Not Process Request');
   47: 	$r->print(<<ENDHEADER);
   48: $html
   49: <head>
   50: <title>The LearningOnline Network with CAPA</title>
   51: </head>
   52: $bodytag
   53: ENDHEADER
   54: 
   55:     if ($env{'form.sendinfo'}) {
   56: 	my $repro='no';
   57: # ------------------------------------------------------------------ Mail stuff
   58: 	if ($env{'form.reproducible'}) {
   59: 	    $repro='yes';
   60: 	}
   61: 	my $message=(<<ENDMESSAGE);
   62: LON-CAPA Error Message
   63: Reproducible: $repro
   64: Version: $env{'form.version'}
   65: Syllabus:
   66: $env{'form.syllabus'}
   67: 
   68: Prior Action:
   69: $env{'form.prioraction'}
   70: 
   71: Guesses:
   72: $env{'form.guesses'}
   73: 
   74: Environment:
   75: $env{'form.environment'}
   76: ENDMESSAGE
   77: 	my $recipients=$r->dir_config('lonAdmEMail').','.
   78: 	    $r->dir_config('lonSysEMail'); 
   79: 
   80:         &Apache::lonmsg::sendemail($recipients,'ERROR REPORT',$message);
   81: 	$r->print('<h2>Report submitted</h2>Thank you!</body></html>');
   82:     } else {
   83: # ------------------------------------------------------------- Get environment
   84: 	my $envkey;
   85: 	my $env='';
   86: 	my $syllabus='';
   87: 
   88: 	foreach $envkey (sort(keys(%env))) {
   89: 	    $env.="$envkey: $env{$envkey}\n";
   90: 	}
   91: 	foreach $envkey (sort(keys(%ENV))) {
   92: 	    $env.="$envkey: $ENV{$envkey}\n";
   93: 	    if ($envkey=~/REDIRECT\_(REQUEST_URI|SCRIPT|ERROR)/) {
   94: 		$syllabus.="\n$1:\n$ENV{$envkey}";
   95: 	    }
   96: 	}
   97: 
   98: 	$env=~s/\"/\'\'/g;
   99: 
  100: 	my $version=$r->dir_config('lonVersion');
  101: 
  102: # ----------------------------------------------------------- Print error form
  103: 	$r->print(<<ENDDOCUMENT);
  104: <h2>Somewhere something went wrong - please help us to find out what.</h2>
  105: Please take a moment to fill out the form below. Your information, together
  106: with internal debugging information, will be emailed to the system and server
  107: administrators.
  108: <form action="/adm/errorhandler" method="post">
  109: <input type="submit" value="Send Information">
  110: <h3>Please describe what you did just before this screen came up</h3>
  111: <textarea name="prioraction" cols="50" rows="5">
  112: </textarea>
  113: <h3>Is this problem reproducible?</h3>
  114: <label>
  115: <input type="checkbox" name="reproducible" value="yes"> Yes!
  116: </label>
  117: <h3>Do you have any guesses why this might have happened?</h3>
  118: <textarea name="guesses" cols="50" rows="5">
  119: </textarea>
  120: <input type="hidden" name="version" value="$version" />
  121: <input type="hidden" name="environment" value="$env" />
  122: <input type="hidden" name="syllabus" value="$syllabus" />
  123: <input type="hidden" name="sendinfo" value="1" />
  124: <p>
  125: <input type="submit" value="Send Information">
  126: </p>
  127: </form>
  128: <h1>Thank you for your help!</h1>
  129: <font size="-1">
  130: <pre>
  131: Internal info:
  132: $syllabus
  133: </pre>
  134: </font>
  135: </body>
  136: </html>
  137: ENDDOCUMENT
  138: # -------------------------- Better terminate this in case something was sticky
  139:         $r->child_terminate();
  140:     }
  141:     return OK;
  142: } 
  143: 
  144: 1;
  145: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>