Skip to content

Commit

Permalink
Merge a031594 into cd550f5
Browse files Browse the repository at this point in the history
  • Loading branch information
karenetheridge committed Nov 21, 2017
2 parents cd550f5 + a031594 commit 26b561d
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ for, noteworthy changes.

{{$NEXT}}

[BUG FIXES]

- fixed empty exception messages under -d (new issue in 2.2007)

2.2007 2017-11-12

[DOCUMENTATION]
Expand Down
4 changes: 2 additions & 2 deletions dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ skip = ^Moose::Meta::TypeConstraint::Union$
;authordep Devel::GlobalDestruction = 0
Devel::OverloadInfo = 0.004
;authordep Devel::OverloadInfo = 0.004
Devel::StackTrace = 1.33
;authordep Devel::StackTrace = 1.33
Devel::StackTrace = 2.03
;authordep Devel::StackTrace = 2.03
Eval::Closure = 0.04
;authordep Eval::Closure = 0.04
List::Util = 1.45
Expand Down
6 changes: 4 additions & 2 deletions lib/Moose/Exception.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package Moose::Exception;
our $VERSION = '2.2008';

use Moose;
use Devel::StackTrace 1.33;
use Devel::StackTrace 2.03;

has 'trace' => (
is => 'ro',
Expand Down Expand Up @@ -36,7 +36,8 @@ sub _build_trace {
# be weakening all references in its frames)
my $skip = 0;
while (my @c = caller(++$skip)) {
last if $c[3] =~ /^(.*)::new$/ && $self->isa($1);
last if ($c[3] =~ /^(.*)::new$/ || $c[3] =~ /^\S+ (.*)::new \(defined at /)
&& $self->isa($1);
}
$skip++;

Expand Down Expand Up @@ -91,6 +92,7 @@ sub as_string {
return $message;
}

__PACKAGE__->meta->make_immutable;
1;

# ABSTRACT: Superclass for Moose internal exceptions
Expand Down
37 changes: 37 additions & 0 deletions t/exceptions/with-debugging.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use strict;
use warnings;

BEGIN {
# t/exceptions/without-debugging.t and t/exceptions/with-debugging.t are
# identical except for this one line.
$^P |= 0x200;
}

use Test::More tests => 2;
use Test::Moose;
use Moose::Exception;

# with_immutable only toggles on, not off
Moose::Exception->meta->make_mutable;

sub foo
{
return Moose::Exception->new(
message => 'something bad happened',
);
}

my $filename = __FILE__;

with_immutable {
my $immutable = shift;

note "testing with immutable = $immutable, \$\^P is $^P";

like(
foo(),
qr{^something bad happened at $filename line \d+\n\tmain::foo at $filename line \d+},
"exception is well-formed (immutable = $immutable)",
);
}
'Moose::Exception';
37 changes: 37 additions & 0 deletions t/exceptions/without-debugging.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use strict;
use warnings;

BEGIN {
# t/exceptions/without-debugging.t and t/exceptions/with-debugging.t are
# identical except for this one line.
$^P &= ~0x200;
}

use Test::More tests => 2;
use Test::Moose;
use Moose::Exception;

# with_immutable only toggles on, not off
Moose::Exception->meta->make_mutable;

sub foo
{
return Moose::Exception->new(
message => 'something bad happened',
);
}

my $filename = __FILE__;

with_immutable {
my $immutable = shift;

note "testing with immutable = $immutable, \$\^P is $^P";

like(
foo(),
qr{^something bad happened at $filename line \d+\n\tmain::foo at $filename line \d+},
"exception is well-formed (immutable = $immutable)",
);
}
'Moose::Exception';

0 comments on commit 26b561d

Please sign in to comment.