Skip to content

Instantly share code, notes, and snippets.

@nicomen
Created April 5, 2018 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicomen/312fb3ceea10aac3cc3e7af2693faede to your computer and use it in GitHub Desktop.
Save nicomen/312fb3ceea10aac3cc3e7af2693faede to your computer and use it in GitHub Desktop.
Mojo::CarpAlways
package MojoCarpAlways;
use Mojo::Base -strict;
use Mojo::Exception;
*Mojo::Exception::to_string = sub {
my $self = shift;
my $str = $self->message;
$str .= join "\n", map { " $_->[1]: " . $_->[2] } @{ $self->frames };
return $str unless $self->verbose;
$str .= "\n" unless $str =~ /\n$/;
$str .= $_->[0] . ': ' . $_->[1] . "\n" for @{$self->lines_before};
$str .= $self->line->[0] . ': ' . $self->line->[1] . "\n" if $self->line->[0];
$str .= $_->[0] . ': ' . $_->[1] . "\n" for @{$self->lines_after};
return $str;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment