Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
By default, exceptions now eliminate most of the Moose internals from…
… stack traces
- Loading branch information
Showing
3 changed files
with
130 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
use strict; | ||
use warnings; | ||
|
||
use Test::More; | ||
use Try::Tiny; | ||
|
||
{ | ||
my $e; | ||
{ | ||
package Foo; | ||
use Moose; | ||
use Try::Tiny; | ||
|
||
try { | ||
has '+foo' => ( is => 'ro' ); | ||
} | ||
catch { | ||
$e = $_; | ||
}; | ||
} | ||
|
||
ok( $e, q{got an exception from a bad has '+foo' declaration} ); | ||
like( | ||
$e->as_string, | ||
qr/\QCould not find an attribute by the name of 'foo' to inherit from in Foo/, | ||
'stringification includes the error message' | ||
); | ||
like( | ||
$e->as_string, | ||
qr/\s+Moose::has/, | ||
'stringification includes the call to Moose::has' | ||
); | ||
unlike( | ||
$e->as_string, | ||
qr/Moose::Meta/, | ||
'stringification does not include internal calls to Moose meta classes' | ||
); | ||
} | ||
|
||
local $ENV{MOOSE_FULL_EXCEPTION} = 1; | ||
{ | ||
my $e; | ||
{ | ||
package Bar; | ||
use Moose; | ||
use Try::Tiny; | ||
|
||
try { | ||
has '+foo' => ( is => 'ro' ); | ||
} | ||
catch { | ||
$e = $_; | ||
}; | ||
} | ||
|
||
ok( $e, q{got an exception from a bad has '+foo' declaration} ); | ||
like( | ||
$e->as_string, | ||
qr/\QCould not find an attribute by the name of 'foo' to inherit from in Bar/, | ||
'stringification includes the error message' | ||
); | ||
like( | ||
$e->as_string, | ||
qr/\s+Moose::has/, | ||
'stringification includes the call to Moose::has' | ||
); | ||
like( | ||
$e->as_string, | ||
qr/Moose::Meta/, | ||
'stringification includes internal calls to Moose meta classes when MOOSE_FULL_EXCEPTION env var is true' | ||
); | ||
} | ||
|
||
done_testing; |