summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>2011-12-20 09:58:24 +0000
committerGianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>2011-12-20 09:58:24 +0000
commitf39fe87635aa24eee61d89092fe0f604237822d5 (patch)
treee3323f8f1460c75ef605a8125f4163582d2b3649
parenthack to stop leaks via exceptions (diff)
downloaddata-multivalued-f39fe87635aa24eee61d89092fe0f604237822d5.tar.gz
data-multivalued-f39fe87635aa24eee61d89092fe0f604237822d5.tar.bz2
data-multivalued-f39fe87635aa24eee61d89092fe0f604237822d5.zip
lighter exception classes
these ones don't leak
-rw-r--r--lib/Data/MultiValued/AttributeTrait.pm2
-rw-r--r--lib/Data/MultiValued/Exceptions.pm28
2 files changed, 14 insertions, 16 deletions
diff --git a/lib/Data/MultiValued/AttributeTrait.pm b/lib/Data/MultiValued/AttributeTrait.pm
index b2876b9..eb8cbd3 100644
--- a/lib/Data/MultiValued/AttributeTrait.pm
+++ b/lib/Data/MultiValued/AttributeTrait.pm
@@ -271,8 +271,6 @@ sub load_multi_value {
unless (ref($_) && $_->isa('Data::MultiValued::Exceptions::NotFound')) {
die $_;
}
- # XXX FIXME horrible hack to prevent StackTrace::Auto from leaking
- delete $_->{stack_trace};
$found = 0;
};
diff --git a/lib/Data/MultiValued/Exceptions.pm b/lib/Data/MultiValued/Exceptions.pm
index 6495780..84d6ffa 100644
--- a/lib/Data/MultiValued/Exceptions.pm
+++ b/lib/Data/MultiValued/Exceptions.pm
@@ -18,7 +18,15 @@ containing the value that was not found.
package Data::MultiValued::Exceptions::NotFound;{
use Moose;
-extends 'Throwable::Error';
+with 'Throwable';
+use overload
+ q{""} => 'as_string',
+ fallback => 1;
+
+has message => (
+ is => 'ro',
+ required => 1,
+);
has value => (
is => 'ro',
@@ -29,7 +37,6 @@ sub as_string {
my ($self) = @_;
my $str = $self->message . ($self->value // '<undef>');
- $str .= "\n\n" . $self->stack_trace->as_string;
return $str;
}
@@ -42,8 +49,6 @@ tags. Stringifies to:
tag not found: $value
- $stack_trace
-
=cut
package Data::MultiValued::Exceptions::TagNotFound;{
@@ -62,8 +67,6 @@ ranges. Stringifies to:
no range found for value: $value
- $stack_trace
-
=cut
package Data::MultiValued::Exceptions::RangeNotFound;{
@@ -84,24 +87,21 @@ Stringifies to:
invalid range: $from, $to
- $stack_trace
-
=cut
package Data::MultiValued::Exceptions::BadRange;{
use Moose;
-extends 'Throwable::Error';
+with 'Throwable';
+use overload
+ q{""} => 'as_string',
+ fallback => 1;
has ['from','to'] => ( is => 'ro', required => 1 );
-has '+message' => (
- default => 'invalid range: ',
-);
sub as_string {
my ($self) = @_;
- my $str = $self->message . $self->from . ', ' . $self->to;
- $str .= "\n\n" . $self->stack_trace->as_string;
+ my $str = 'invalid range: ' . $self->from . ', ' . $self->to;
return $str;
}