Skip to content

Commit

Permalink
Item13897: A little bit of formatting when exception is being stringi…
Browse files Browse the repository at this point in the history
…fied with "" operator.
  • Loading branch information
vrurg committed Oct 28, 2016
1 parent ba60d96 commit 5e2e07c
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions core/lib/Foswiki/Exception.pm
Expand Up @@ -57,7 +57,7 @@ use Foswiki::Class;
extends qw(Foswiki::Object);
with 'Throwable';

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

our $EXCEPTION_TRACE = 0;

Expand Down Expand Up @@ -185,6 +185,16 @@ sub stringify {
);
}

sub to_str {
my $this = shift;

my $boundary = '-' x 60;
my $msg = join( "\n",
$boundary, map( { " " . $_ } split /\n/, $this->stringify ),
$boundary );
return $msg;
}

# We must not get into this. But if we do then let's not hide a error but let it
# thru to the end user via JsonRPC interfaces.
sub TO_JSON {
Expand Down Expand Up @@ -402,11 +412,11 @@ use Assert;
use Foswiki::Class;
extends qw(Foswiki::Exception);

sub BUILD {
my $this = shift;

say STDERR $this->stringify, $this->stacktrace if DEBUG;
}
#sub BUILD {
# my $this = shift;
#
# say STDERR $this->stringify, $this->stacktrace if DEBUG;
#}

# To cover perl/system errors.

Expand Down

0 comments on commit 5e2e07c

Please sign in to comment.