Annotation of loncom/interface/lonerrorhandler.pm, revision 1.19
1.1 www 1: # The LearningOnline Network
2: # Internal Server Error Handler
3: #
1.19 ! jms 4: # $Id: lonerrorhandler.pm,v 1.18 2008/11/17 14:11:24 schafran 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.19 ! jms 29: =pod
! 30:
! 31: =head1 NAME
! 32:
! 33: Apache::lonerrorhandler.pm
! 34:
! 35: =head1 SYNOPSIS
! 36:
! 37: Handles errors.
! 38:
! 39: This is part of the LearningOnline Network with CAPA project
! 40: described at http://www.lon-capa.org.
! 41:
! 42: =head1 OVERVIEW
! 43:
! 44: None
! 45:
! 46: =cut
! 47:
1.1 www 48: package Apache::lonerrorhandler;
49:
50: use strict;
51: use Apache::Constants qw(:common);
1.11 albertel 52: use Apache::loncommon();
1.7 albertel 53: use Apache::lonnet;
1.11 albertel 54: use Apache::lonmsg();
55: use Apache::lonacc();
1.13 raeburn 56: use Apache::lonlocal;
1.1 www 57:
58: sub handler {
59: my $r = shift;
1.6 albertel 60: &Apache::loncommon::content_type($r,'text/html');
1.1 www 61: $r->send_http_header;
62: return OK if $r->header_only;
63:
1.11 albertel 64: &Apache::lonacc::get_posted_cgi($r);
1.17 raeburn 65: if (!$Apache::lonlocal::lh) {
1.16 raeburn 66: &Apache::lonlocal::get_language_handle($r);
67: }
1.9 albertel 68: my $title = $env{'form.sendinfo'} ? 'Sending Error Report'
69: : 'Could Not Process Request';
70: $r->print(&Apache::loncommon::start_page($title));
1.8 www 71:
72: if ($env{'form.sendinfo'}) {
73: my $repro='no';
74: # ------------------------------------------------------------------ Mail stuff
75: if ($env{'form.reproducible'}) {
76: $repro='yes';
77: }
1.13 raeburn 78: my %lt = &Apache::lonlocal::texthash (
79: msg => 'LON-CAPA Error Message',
80: rep => 'Reproducible',
81: ver => 'Version',
82: syl => 'Syllabus',
83: pri => 'Prior Action',
84: gue => 'Guesses',
85: env => 'Environment',
86: );
1.8 www 87: my $message=(<<ENDMESSAGE);
1.13 raeburn 88: $lt{'msg'}
89: $lt{'rep'}: $repro
90: $lt{'ver'}: $env{'form.version'}
91: $lt{'syl'}:
1.8 www 92: $env{'form.syllabus'}
93:
1.13 raeburn 94: $lt{'pri'}:
1.8 www 95: $env{'form.prioraction'}
96:
1.13 raeburn 97: $lt{'gue'}:
1.8 www 98: $env{'form.guesses'}
99:
1.13 raeburn 100: $lt{'env'}:
1.8 www 101: $env{'form.environment'}
102: ENDMESSAGE
1.13 raeburn 103: my $sysmail = $r->dir_config('lonSysEMail');
104: my $defdom = $r->dir_config('lonDefDomain');
1.14 raeburn 105: my $origmail = $r->dir_config('lonAdmEMail');
106: my $recipients = &Apache::loncommon::build_recipient_list($sysmail,
107: 'errormail',$defdom,$origmail);
1.13 raeburn 108: if ($recipients ne '') {
109: &Apache::lonmsg::sendemail($recipients,'ERROR REPORT',$message);
110: $r->print('<h2>'.&mt('Report submitted').'</h2>'.&mt('Thank you!'));
111: } else {
112: $r->print('<h2>'.&mt('Warning: Report not submitted').'</h2>'.
1.15 bisitz 113: '<span class="LC_error">'
114: .&mt('The administrators of the domain [_1] have not set'
115: .' any e-mail addresses for receipt of your error report.'
116: ,'<tt>'.$defdom.'</tt>')
117: .'</span>');
1.13 raeburn 118: }
1.8 www 119: } else {
120: # ------------------------------------------------------------- Get environment
121: my $envkey;
122: my $env='';
123: my $syllabus='';
124:
125: foreach $envkey (sort(keys(%env))) {
126: $env.="$envkey: $env{$envkey}\n";
127: }
128: foreach $envkey (sort(keys(%ENV))) {
129: $env.="$envkey: $ENV{$envkey}\n";
130: if ($envkey=~/REDIRECT\_(REQUEST_URI|SCRIPT|ERROR)/) {
131: $syllabus.="\n$1:\n$ENV{$envkey}";
132: }
133: }
134:
135: $env=~s/\"/\'\'/g;
136:
137: my $version=$r->dir_config('lonVersion');
138:
139: # ----------------------------------------------------------- Print error form
1.15 bisitz 140: $r->print('<h2 class="LC_error">'
141: .&mt('Somewhere something went wrong')
142: .'</h2>'
143: .'<p>'.&mt('Please help us to find out what.').'</p>'
144: .'<p>'.&mt('Please take a moment to fill out the form below.').' '
145: .&mt('Your information, together with internal debugging information, '
146: .'will be emailed to the system and server administrators.')
147: .'</p>
1.8 www 148: <form action="/adm/errorhandler" method="post">
1.13 raeburn 149: <h3>'.&mt('Please describe what you did just before this screen came up').'</h3>
1.8 www 150: <textarea name="prioraction" cols="50" rows="5">
1.2 www 151: </textarea>
1.13 raeburn 152: <h3>'.&mt('Is this problem reproducible?').'</h3>
1.8 www 153: <label>
1.13 raeburn 154: <input type="checkbox" name="reproducible" value="yes" /> '.&mt('Yes!').'
1.8 www 155: </label>
1.13 raeburn 156: <h3>'.&mt('Do you have any guesses why this might have happened?').'</h3>
1.8 www 157: <textarea name="guesses" cols="50" rows="5">
1.2 www 158: </textarea>
1.13 raeburn 159: <input type="hidden" name="version" value="'.$version.'" />
160: <input type="hidden" name="environment" value="'.$env.'" />
161: <input type="hidden" name="syllabus" value="'.$syllabus.'" />
1.8 www 162: <input type="hidden" name="sendinfo" value="1" />
163: <p>
1.18 schafran 164: <input type="submit" title="Send Information" value="'.&mt('Send').'" />
1.8 www 165: </p>
1.2 www 166: </form>
1.13 raeburn 167: <h1>'.&mt('Thank you for your help!').'</h1>
1.15 bisitz 168: <div><font size="-1">
1.13 raeburn 169: '.&mt('Internal info:').
1.15 bisitz 170: '<pre>'.
1.13 raeburn 171: $syllabus.'
1.8 www 172: </pre>
1.15 bisitz 173: </font></div>
1.13 raeburn 174: ');
1.2 www 175: # -------------------------- Better terminate this in case something was sticky
1.9 albertel 176:
1.8 www 177: $r->child_terminate();
178: }
1.10 albertel 179: $r->print(&Apache::loncommon::end_page());
1.1 www 180: return OK;
1.13 raeburn 181: }
1.1 www 182:
183: 1;
184: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>