summaryrefslogtreecommitdiff
path: root/lib/Type
diff options
context:
space:
mode:
authorToby Inkster <mail@tobyinkster.co.uk>2023-04-01 17:57:02 +0100
committerToby Inkster <mail@tobyinkster.co.uk>2023-04-01 17:57:02 +0100
commit314c4dd725a9b18c2673415d67298751c66e99de (patch)
treeb98b8ed281d20d40ae352d85d11d1f974f296313 /lib/Type
parentd9841e5baf8781c057325933154d3ff3cf747463 (diff)
Cope with custom exception class in cases where the original type constraint has gone away
Diffstat (limited to 'lib/Type')
-rw-r--r--lib/Type/Tiny.pm5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Type/Tiny.pm b/lib/Type/Tiny.pm
index d7505492..f9b844ce 100644
--- a/lib/Type/Tiny.pm
+++ b/lib/Type/Tiny.pm
@@ -1008,6 +1008,8 @@ sub inline_assert {
my $self = shift;
my ( $varname, $typevarname, %extras ) = @_;
+ $extras{exception_class} ||= $self->exception_class;
+
my $inline_check;
if ( $self->can_be_inlined ) {
$inline_check = sprintf( '(%s)', $self->inline_check( $varname ) );
@@ -1056,7 +1058,8 @@ sub _failed_check {
my ( $self, $name, $value, %attrs ) = @_;
$self = $ALL_TYPES{$self} if defined $self && !ref $self;
- my $exception_class = delete( $attrs{exception_class} ) || $self->exception_class;
+ my $exception_class = delete( $attrs{exception_class} )
+ || ( ref $self ? $self->exception_class : __PACKAGE__->_build_exception_class );
my $callback = delete( $attrs{on_die} );
if ( $self ) {