Changeset 14
- Timestamp:
- 10/04/07 22:35:39 (6 years ago)
- Files:
-
- trunk/lib/Mungo.pm (modified) (2 diffs)
- trunk/lib/Mungo/Arbiter.pm (modified) (1 diff)
- trunk/lib/Mungo/Arbiter/Response.pm (modified) (1 diff)
- trunk/lib/Mungo/Response.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/Mungo.pm
r12 r14 68 68 return $s; 69 69 } 70 71 70 sub URLDecode { 72 71 my $self = shift; … … 208 207 }; 209 208 if($@) { 209 # print out the error to the logs 210 print STDERR $@ if($@); 210 211 # If it isn't too late, make this an internal server error 211 212 eval { $self->Response()->{Status} = 500; }; 212 # print out the error to the logs213 print STDERR $@ if($@);214 213 } 215 214 MUNGO_HANDLER_FINISH: trunk/lib/Mungo/Arbiter.pm
r2 r14 9 9 die "Mungo '$key' is immutable!\n"; 10 10 return 0; 11 } 12 sub __boolean { 13 my ($self, $key, $value) = @_; 14 return 1 if ($value =~ /^(?:0|1)$/); 15 return 0; 16 } 17 sub __coderef { 18 my ($self, $key, $value) = @_; 19 return (ref $value eq 'CODE') ? 1 : 0; 11 20 } 12 21 sub TIEHASH { trunk/lib/Mungo/Arbiter/Response.pm
r2 r14 76 76 'Method' => \&Mungo::Arbiter::__immutable, 77 77 'TotalBytes' => \&__immutable, 78 'OnError' => \&Mungo::Arbiter::__coderef, 78 79 ); 79 80 trunk/lib/Mungo/Response.pm
r13 r14 130 130 }; 131 131 if($@) { 132 use Data::Dumper;133 print "Error in Include($subject):<br />\n";134 132 my $href = $@; 135 133 eval { 136 my $pkg = $href->{callstack}->[0]->[0]; 137 my $preamble = eval "\$${pkg}::Mungo_preamble;"; 138 my $postamble = eval "\$${pkg}::Mungo_postamble;"; 139 my $contents = eval "\$${pkg}::Mungo_contents;"; 140 print "<pre class=\"error\">$href->{error}</pre><br />\n"; 141 142 unless($contents) { 143 my $filename = $href->{callstack}->[0]->[1]; 144 if(open(FILE, "<$filename")) { 145 local $/ = undef; 146 $$contents = <FILE>; 147 close(FILE); 148 } 134 if($self->{OnError}) { 135 $self->{OnError}->($self, $href, $subject); 149 136 } 150 151 if($contents) { 152 if($self->{'Apache::Request'}->dir_config('Debug')) { 153 print Mungo::Utils::pretty_print_code($preamble, $contents, $postamble, $href->{callstack}->[0]->[2]); 154 } 155 } else { 156 print '<pre>'.Dumper($@).'</pre>'; 137 else { 138 $self->defaultErrorHandler($href, $subject); 157 139 } 158 140 }; … … 165 147 return $rv; 166 148 } 149 150 sub defaultErrorHandler { 151 use Data::Dumper; 152 my $self = shift; 153 my $href = shift; # Our Error 154 my $subject = shift; 155 print "Error in Include($subject):<br />\n"; 156 my $pkg = $href->{callstack}->[0]->[0]; 157 my $preamble = eval "\$${pkg}::Mungo_preamble;"; 158 my $postamble = eval "\$${pkg}::Mungo_postamble;"; 159 my $contents = eval "\$${pkg}::Mungo_contents;"; 160 print "<pre class=\"error\">$href->{error}</pre><br />\n"; 161 162 unless($contents) { 163 my $filename = $href->{callstack}->[0]->[1]; 164 if(open(FILE, "<$filename")) { 165 local $/ = undef; 166 $$contents = <FILE>; 167 close(FILE); 168 } 169 } 170 171 if($contents) { 172 if($self->{'Apache::Request'}->dir_config('Debug')) { 173 print Mungo::Utils::pretty_print_code($preamble, $contents, $postamble, $href->{callstack}->[0]->[2]); 174 } 175 } else { 176 print '<pre>'.Dumper($@).'</pre>'; 177 } 178 } 179 167 180 sub TrapInclude { 168 181 my $self = shift;
