From 06cf0a8c7a4039a5fd3f794517559bf4cd2e092c Mon Sep 17 00:00:00 2001 From: Daniel Asher Resnick Date: Wed, 3 Jan 2024 15:40:45 -0600 Subject: [PATCH] Carp instead of croak when recoverable/abortable --- HexGrid/Tile.pm | 8 ++++---- wiki-map.pl | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/HexGrid/Tile.pm b/HexGrid/Tile.pm index b08f23e..260ea19 100644 --- a/HexGrid/Tile.pm +++ b/HexGrid/Tile.pm @@ -63,14 +63,14 @@ sub pin($this, $pin, $dock = undef) { foreach my $dock (keys %$pin) { - croak "dock $dock doesn't exist" unless grep { $_ eq $dock } keys %docks; + (carp("dock $dock doesn't exist") && return) unless grep { $_ eq $dock } keys %docks; $this->{pins}{$dock} = $pin->{$dock}; } return; } else { - croak "bad pin type"; + carp ("bad pin type") && return; } } @@ -78,7 +78,7 @@ sub _do_pin($this, $pin, $dock = undef) { if($dock) { - croak "bad dock" unless $dock =~ /^sw|se|n$/i; + (carp("bad dock") && retrun) unless $dock =~ /^sw|se|n$/i; $this->{pins}{$dock} = $pin; } else @@ -94,7 +94,7 @@ sub _do_pin($this, $pin, $dock = undef) last DOCK; } } - croak "no free dock" unless $success; + (carp("no free dock") && return) unless $success; } } diff --git a/wiki-map.pl b/wiki-map.pl index bfe8ae2..463e731 100644 --- a/wiki-map.pl +++ b/wiki-map.pl @@ -419,7 +419,7 @@ if($regiondir) { say STDERR "Rendering Location $location_name\'s grid"; open (my $location_fh, "> $location_name.$extension") - or croak "Couldn't open $location_name.extension for writing: $!"; + or croak "Couldn't open $location_name.$extension for writing: $!"; say $location_fh ($html_document ? wrap_in_html($location_grid) : $location_grid->render); close $location_fh; }