Changeset 10

Show
Ignore:
Timestamp:
08/09/07 03:37:19 (7 years ago)
Author:
jesus
Message:

So, this magic DIE overloading has caused the expected behanviour
or die to not work within normal evals. This is bad.

We will die with a Mungo::Error class that can act like a string, a bool,
and a representative hash.

refs #3

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/Mungo.pm

    r8 r10  
    1414use Mungo::Request; 
    1515use Mungo::Response; 
     16use Mungo::Error; 
    1617use HTML::Entities; 
    1718 
     
    3536    push @callstack, \@callinfo; 
    3637  } 
    37   die { error => shift, callstack => \@callstack }
     38  die Mungo::Error->new({ error => shift, callstack => \@callstack })
    3839} 
    3940 
     
    129130  my $page = bless \%copy, $pkg; 
    130131  $page->content(@_); 
    131 } 
    132 sub pretty_print_code { 
    133   my ($preamble, $contents, $postamble, $line) = @_; 
    134   my $outer_line = 1; 
    135   my $inner_line = 1; 
    136   my $rv = ''; 
    137   my $numbered_preamble = ''; 
    138   if(defined($preamble)) { 
    139     ($numbered_preamble = $preamble) =~ 
    140       s/^/sprintf("[ %4d]       ", $outer_line++)/emg; 
    141     $rv .= qq^<pre style="color: #999">$numbered_preamble</pre>\n^; 
    142   } 
    143   (my $numbered_contents = $$contents) =~ 
    144     s/^/sprintf("[%s%4d] %4d: ", ($outer_line == $line)?'*':' ', 
    145                 $outer_line++, $inner_line++)/emg; 
    146   $numbered_contents = HTML::Entities::encode($numbered_contents); 
    147   $rv .= "<pre>$numbered_contents</pre>\n"; 
    148   my $numbered_postamble; 
    149   if(defined($postamble)) { 
    150     ($numbered_postamble = $postamble) =~ 
    151       s/^/sprintf("[ %4d]       ", $outer_line++)/emg; 
    152     $rv .= qq^<pre style="color: #999">$numbered_postamble</pre>\n\n^; 
    153   } 
    154   return $rv; 
    155132} 
    156133sub packagize { 
  • trunk/lib/Mungo/Response.pm

    r9 r10  
    1010use Mungo::Response::Trap; 
    1111use Mungo::Cookie; 
     12use Mungo::Utils; 
    1213use HTML::Entities; 
    1314our $AUTOLOAD; 
     
    150151      if($contents) { 
    151152        if($self->{'Apache::Request'}->dir_config('Debug')) { 
    152           print Mungo::pretty_print_code($preamble, $contents, $postamble, $href->{callstack}->[0]->[2]); 
     153          print Mungo::Utils::pretty_print_code($preamble, $contents, $postamble, $href->{callstack}->[0]->[2]); 
    153154        } 
    154155      } else { 
  • trunk/lib/Mungo/Utils.pm

    r2 r10  
    3232} 
    3333 
     34sub pretty_print_code { 
     35  my ($preamble, $contents, $postamble, $line) = @_; 
     36  my $outer_line = 1; 
     37  my $inner_line = 1; 
     38  my $rv = ''; 
     39  my $numbered_preamble = ''; 
     40  if(defined($preamble)) { 
     41    ($numbered_preamble = $preamble) =~ 
     42      s/^/sprintf("[ %4d]       ", $outer_line++)/emg; 
     43    $rv .= qq^<pre style="color: #999">$numbered_preamble</pre>\n^; 
     44  } 
     45  (my $numbered_contents = $$contents) =~ 
     46    s/^/sprintf("[%s%4d] %4d: ", ($outer_line == $line)?'*':' ', 
     47                $outer_line++, $inner_line++)/emg; 
     48  $numbered_contents = HTML::Entities::encode($numbered_contents); 
     49  $rv .= "<pre>$numbered_contents</pre>\n"; 
     50  my $numbered_postamble; 
     51  if(defined($postamble)) { 
     52    ($numbered_postamble = $postamble) =~ 
     53      s/^/sprintf("[ %4d]       ", $outer_line++)/emg; 
     54    $rv .= qq^<pre style="color: #999">$numbered_postamble</pre>\n\n^; 
     55  } 
     56  return $rv; 
     57} 
     58 
    34591;