Mojo::Exception - Exceptions with context
use Mojo::Exception; # Throw exception Mojo::Exception->throw('Not again!'); # Customize exception die Mojo::Exception->new('Not again!')->trace(2)->verbose(1);
Mojo::Exception is a container for exceptions with context information.
Mojo::Exception implements the following attributes.
my $frames = $e->frames; $e = $e->frames($frames);
Stacktrace.
my $line = $e->line; $e = $e->line([3 => 'foo']);
The line where the exception occurred.
my $lines = $e->lines_after; $e = $e->lines_after([[1 => 'bar'], [2 => 'baz']]);
Lines after the line where the exception occurred.
my $lines = $e->lines_before; $e = $e->lines_before([[4 => 'bar'], [5 => 'baz']]);
Lines before the line where the exception occurred.
my $msg = $e->message; $e = $e->message('Oops!');
Exception message.
my $bool = $e->verbose; $e = $e->verbose($bool);
Render exception with context.
Mojo::Exception inherits all methods from Mojo::Base and implements the following new ones.
my $e = Mojo::Exception->new; my $e = Mojo::Exception->new('Oops!'); my $e = Mojo::Exception->new('Oops!', $files);
Construct a new Mojo::Exception object.
Mojo::Exception->throw('Oops!'); Mojo::Exception->throw('Oops!', $files);
Throw exception with stacktrace.
my $str = $e->to_string;
Render exception.
$e = $e->trace; $e = $e->trace(2);
Store stacktrace.
Mojo::Exception overloads the following operators.
my $bool = !!$e;
Always true.
my $str = "$e";
Alias for "to_string".
Mojolicious, Mojolicious::Guides, http://mojolicio.us.
To install Mojolicious, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious
CPAN shell
perl -MCPAN -e shell install Mojolicious
For more information on module installation, please visit the detailed CPAN module installation guide.