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