/[Frey]/trunk/lib/Frey/Web.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/Web.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 653 by dpavlin, Sun Nov 30 23:49:32 2008 UTC revision 674 by dpavlin, Tue Dec 2 01:49:49 2008 UTC
# Line 225  sub page { Line 225  sub page {
225          if ( ! $body ) {          if ( ! $body ) {
226                  my $run = $a->{run} || 'as_markup';                  my $run = $a->{run} || 'as_markup';
227                  warn "# no body, invoke $self->$run on ", ref($self);                  warn "# no body, invoke $self->$run on ", ref($self);
228                  $body = $self->$run;                  eval {
229                            $body = $self->$run;
230                    };
231                    $body = $self->error( $@, '' ) if $@;
232          }          }
233          if ( $self->content_type !~ m{html} ) {          if ( $self->content_type !~ m{html} ) {
234                  warn "# return only $self body ", $self->content_type;                  warn "# return only $self body ", $self->content_type;
# Line 314  sub editor_links { Line 317  sub editor_links {
317    
318  #       $error =~ s[(bless\({\s+.+?\s+},\s+)("[^"]+")(\) at)][<span class="frey-dropdown">$1<code>$2</code>$3</span>]gs; # FIXME insert bless hiding back  #       $error =~ s[(bless\({\s+.+?\s+},\s+)("[^"]+")(\) at)][<span class="frey-dropdown">$1<code>$2</code>$3</span>]gs; # FIXME insert bless hiding back
319    
320            # perl's backtrace
321          $error =~ s{at\s+(\S+)\s+line\s+(\d+)}          $error =~ s{at\s+(\S+)\s+line\s+(\d+)}
322                  {at <a target="editor" href="/editor+$1+$2">$1</a> line $2}gsm;                  {at <a target="editor" href="/editor+$1+$2">$1</a> line $2}gsm;
323    
324          $error =~ s{(via (?:package) "?)([\w:]+)("?)}          $error =~ s{(via (?:package)\s+"?)([\w:]+)("?)}
325                  {$1<a target="editor" href="/editor+$2+1">$2</a>$3}gsm;                  {$1<a target="$2" href="/$2">$2</a>$3}gsm;
326    
327            # method error messages
328    #       $error =~ s{(method ")(\w+)"}
329    #               {$1<a target="/Frey::Shell::Grep?pattern=$2">$2</a>"}gsm; # FIXME replace with link to Frey::Introspect data
330    
331            # anything that looks like "Class::Name"
332            $error =~ s{"(\w+(?:::\w+)+)"}
333                    {"<a target="$1" href="/$1">$1</a>"}gsm;
334    
335          return $error;          return $error;
336  }  }
337    
338    =head2 error
339    
340    This method will return error to browser and backtrace unless
341    error message ends with LF C<\n> just like L<warn>
342    
343    =cut
344    
345  sub error {  sub error {
346          my $self = shift;          my $self = shift;
347          my $error = join(" ", @_);          my $error = join(" ", @_);
348    
349          my @backtrace = $self->backtrace;          my $fatal = '';
350          $error .= "\n\t" . join( "\n\t", @backtrace ) if @backtrace;  
351            if ( $error !~ m{\n$} ) {
352                    if ( my @backtrace = $self->backtrace ) {
353                            $error .= "\n\t" . join( "\n\t", @backtrace );
354                            $fatal = qq| class="fatal"|;
355                    }
356            }
357    
358          warn "ERROR: $error\n";          warn "ERROR: $error\n";
359          return          return
360                  qq|<pre class="frey-error">|                  qq|<pre class="frey-error$fatal">|
361                  . $self->editor_links( $error ) .                  . $self->editor_links( $error ) .
362                  qq|</pre>|                  qq|</pre>|
363                  ;                  ;
# Line 461  my $multiline_markers = { Line 486  my $multiline_markers = {
486          '"' => '"',          '"' => '"',
487  };  };
488    
489    =for later
490    
491  my $multiline_re = '[\\' . join('\\', keys %$multiline_markers ) . ']';  my $multiline_re = '[\\' . join('\\', keys %$multiline_markers ) . ']';
492  warn "## multiline markers ", dump( $multiline_markers ), " -> $multiline_re";  warn "## multiline markers ", dump( $multiline_markers ), " -> $multiline_re";
493    
494    =cut
495    
496  sub log_path {  sub log_path {
497          $Frey::Bootstrap::log_path || die "no log_path?";          $Frey::Bootstrap::log_path || die "no log_path?";
498  }  }
# Line 600  sub backtrace { Line 629  sub backtrace {
629                  ) = caller($_) or last;                  ) = caller($_) or last;
630    
631                  push @backtrace,                  push @backtrace,
632                          qq|via $package at $path line $line|;                          qq|via "$package" at $path line $line|;
633          }          }
634          #warn "# backtrace: ", dump( @backtrace ) if @backtrace;          #warn "# backtrace: ", dump( @backtrace ) if @backtrace;
635          return @backtrace;          return @backtrace;

Legend:
Removed from v.653  
changed lines
  Added in v.674

  ViewVC Help
Powered by ViewVC 1.1.26