NAME
Mojo::Exception - Exceptions with context
SYNOPSIS
use Mojo::Exception;
# Throw exception
Mojo::Exception->throw('Not again!');
# Customize exception
die Mojo::Exception->new('Not again!')->trace(2)->verbose(1);
DESCRIPTION
Mojo::Exception is a container for exceptions with context information.
ATTRIBUTES
Mojo::Exception implements the following attributes.
frames
my $frames = $e->frames;
$e = $e->frames($frames);
Stacktrace.
line
my $line = $e->line;
$e = $e->line([3 => 'foo']);
The line where the exception occured.
lines_after
my $lines = $e->lines_after;
$e = $e->lines_after([[1 => 'bar'], [2 => 'baz']]);
Lines after the line where the exception occured.
lines_before
my $lines = $e->lines_before;
$e = $e->lines_before([[4 => 'bar'], [5 => 'baz']]);
Lines before the line where the exception occured.
message
my $msg = $e->message;
$e = $e->message('Oops!');
Exception message.
verbose
my $verbose = $e->verbose;
$e = $e->verbose(1);
Activate verbose rendering, defaults to the value of the MOJO_EXCEPTION_VERBOSE environment variable or 0
.
METHODS
Mojo::Exception inherits all methods from Mojo::Base and implements the following new ones.
new
my $e = Mojo::Exception->new('Oops!');
my $e = Mojo::Exception->new('Oops!', $files);
Construct a new Mojo::Exception object.
throw
Mojo::Exception->throw('Oops!');
Mojo::Exception->throw('Oops!', $files);
Throw exception with stacktrace.
to_string
my $string = $e->to_string;
my $string = "$e";
Render exception.
trace
$e = $e->trace;
$e = $e->trace(2);
Store stacktrace.