From 3e264463781b8d08f6e81aafd57f18c6d9550c92 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Sun, 5 Dec 2021 20:45:20 +0100 Subject: [PATCH] Lieferschein TypeData: croak wenn typ nicht existiert --- SL/DB/DeliveryOrder/TypeData.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SL/DB/DeliveryOrder/TypeData.pm b/SL/DB/DeliveryOrder/TypeData.pm index 7cde08ede..c65e7ffe4 100644 --- a/SL/DB/DeliveryOrder/TypeData.pm +++ b/SL/DB/DeliveryOrder/TypeData.pm @@ -154,12 +154,14 @@ sub is_valid_type { sub validate_type { my ($type) = @_; - return $valid_types{$type} // confess "invalid type '$type'"; + return $valid_types{$type} // croak "invalid type '$type'"; } sub get { my ($type, $key) = @_; + croak "invalid type '$type'" unless exists $type_data{$type}; + my $ret = $type_data{$type}->{$key} // die "unknown property '$key'"; ref $ret eq 'CODE' @@ -170,7 +172,9 @@ sub get { sub get3 { my ($type, $topic, $key) = @_; - my $ret = $type_data{$type}{$topic}{$key} // die "unknown property '$key' in topic '$topic' for type '$type'"; + croak "invalid type '$type'" unless exists $type_data{$type}; + + my $ret = $type_data{$type}{$topic}{$key} // croak "unknown property '$key' in topic '$topic' for type '$type'"; ref $ret eq 'CODE' ? $ret->() -- 2.20.1