Skip to content

Commit

Permalink
Item13897: A bit of improvement to stringify()
Browse files Browse the repository at this point in the history
  • Loading branch information
vrurg committed Dec 1, 2016
1 parent e284891 commit c888484
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions core/lib/Foswiki/Exception.pm
Expand Up @@ -57,8 +57,6 @@ use Foswiki::Class;
extends qw(Foswiki::Object);
with 'Throwable';

#use overload '""' => 'to_str';

our $EXCEPTION_TRACE = 0;

=begin TML
Expand Down Expand Up @@ -174,18 +172,23 @@ sub BUILD {
if DEBUG && $EXCEPTION_TRACE;
}

sub stringify {
sub stringifyPostfix {
my $this = shift;

return $this->text
. (
return (
DEBUG
? "\n" . $this->stacktrace
: ' at ' . $this->file . ' line ' . $this->line
);
);
}

sub stringify {
my $this = shift;

return $this->text . $this->stringifyPostfix;
}

around to_str => sub {
my $orig = shift;
my $this = shift;

my $boundary = '-' x 60;
Expand Down Expand Up @@ -593,7 +596,7 @@ around stringify => sub {
$res->print( $this->status . " "
. $this->header . "\n\n"
. $this->text
. ( DEBUG ? $this->stacktrace : '' ) );
. $this->stringifyPostfix );
}

return $orig->($this);
Expand Down

0 comments on commit c888484

Please sign in to comment.