Annotation of loncom/interface/lonerrorhandler.pm, revision 1.10
1.1 www 1: # The LearningOnline Network
2: # Internal Server Error Handler
3: #
1.10 ! albertel 4: # $Id: lonerrorhandler.pm,v 1.9 2006/03/19 22:34:30 albertel Exp $
1.3 albertel 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: #
1.4 www 28:
1.1 www 29: package Apache::lonerrorhandler;
30:
31: use strict;
32: use Apache::Constants qw(:common);
1.4 www 33: use Apache::loncommon;
1.7 albertel 34: use Apache::lonnet;
1.8 www 35: use Apache::lonmsg;
1.1 www 36:
37: sub handler {
38: my $r = shift;
1.6 albertel 39: &Apache::loncommon::content_type($r,'text/html');
1.1 www 40: $r->send_http_header;
41: return OK if $r->header_only;
42:
1.8 www 43: &Apache::loncommon::get_posted_cgi($r);
1.2 www 44:
1.9 albertel 45: my $title = $env{'form.sendinfo'} ? 'Sending Error Report'
46: : 'Could Not Process Request';
47: $r->print(&Apache::loncommon::start_page($title));
1.8 www 48:
49: if ($env{'form.sendinfo'}) {
50: my $repro='no';
51: # ------------------------------------------------------------------ Mail stuff
52: if ($env{'form.reproducible'}) {
53: $repro='yes';
54: }
55: my $message=(<<ENDMESSAGE);
56: LON-CAPA Error Message
57: Reproducible: $repro
58: Version: $env{'form.version'}
59: Syllabus:
60: $env{'form.syllabus'}
61:
62: Prior Action:
63: $env{'form.prioraction'}
64:
65: Guesses:
66: $env{'form.guesses'}
67:
68: Environment:
69: $env{'form.environment'}
70: ENDMESSAGE
71: my $recipients=$r->dir_config('lonAdmEMail').','.
72: $r->dir_config('lonSysEMail');
73:
74: &Apache::lonmsg::sendemail($recipients,'ERROR REPORT',$message);
1.10 ! albertel 75: $r->print('<h2>Report submitted</h2>Thank you!');
1.8 www 76: } else {
77: # ------------------------------------------------------------- Get environment
78: my $envkey;
79: my $env='';
80: my $syllabus='';
81:
82: foreach $envkey (sort(keys(%env))) {
83: $env.="$envkey: $env{$envkey}\n";
84: }
85: foreach $envkey (sort(keys(%ENV))) {
86: $env.="$envkey: $ENV{$envkey}\n";
87: if ($envkey=~/REDIRECT\_(REQUEST_URI|SCRIPT|ERROR)/) {
88: $syllabus.="\n$1:\n$ENV{$envkey}";
89: }
90: }
91:
92: $env=~s/\"/\'\'/g;
93:
94: my $version=$r->dir_config('lonVersion');
95:
96: # ----------------------------------------------------------- Print error form
97: $r->print(<<ENDDOCUMENT);
1.2 www 98: <h2>Somewhere something went wrong - please help us to find out what.</h2>
99: Please take a moment to fill out the form below. Your information, together
100: with internal debugging information, will be emailed to the system and server
101: administrators.
1.8 www 102: <form action="/adm/errorhandler" method="post">
103: <input type="submit" value="Send Information">
1.2 www 104: <h3>Please describe what you did just before this screen came up</h3>
1.8 www 105: <textarea name="prioraction" cols="50" rows="5">
1.2 www 106: </textarea>
107: <h3>Is this problem reproducible?</h3>
1.8 www 108: <label>
109: <input type="checkbox" name="reproducible" value="yes"> Yes!
110: </label>
1.2 www 111: <h3>Do you have any guesses why this might have happened?</h3>
1.8 www 112: <textarea name="guesses" cols="50" rows="5">
1.2 www 113: </textarea>
1.8 www 114: <input type="hidden" name="version" value="$version" />
115: <input type="hidden" name="environment" value="$env" />
116: <input type="hidden" name="syllabus" value="$syllabus" />
117: <input type="hidden" name="sendinfo" value="1" />
118: <p>
119: <input type="submit" value="Send Information">
120: </p>
1.2 www 121: </form>
122: <h1>Thank you for your help!</h1>
1.8 www 123: <font size="-1">
124: <pre>
125: Internal info:
126: $syllabus
127: </pre>
128: </font>
1.1 www 129: ENDDOCUMENT
1.2 www 130: # -------------------------- Better terminate this in case something was sticky
1.9 albertel 131:
1.8 www 132: $r->child_terminate();
133: }
1.10 ! albertel 134: $r->print(&Apache::loncommon::end_page());
1.1 www 135: return OK;
136: }
137:
138: 1;
139: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>