From 29a4127eb66fca3163429c9668836a25aa39f684 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 14 Jul 2023 10:35:06 +0000 Subject: [PATCH] Bug 33871: Add try catch in case where parameter is not valid SQL Hi Marcel is this try catch a good idea or irrelevant and unecessary? Also, shoul we keep at least 1 test for ->run() (without params) in Sitemapper.t? The where param in Sitemapper->run is optional, I think should still test for ->run() --- Koha/Sitemapper.pm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Koha/Sitemapper.pm b/Koha/Sitemapper.pm index 6c2520781d..a800a10614 100644 --- a/Koha/Sitemapper.pm +++ b/Koha/Sitemapper.pm @@ -19,6 +19,7 @@ package Koha::Sitemapper; # along with Koha; if not, see . use Modern::Perl; +use Try::Tiny; use Moo; use Koha::Biblios; @@ -57,13 +58,20 @@ sub run { say "Creation of Sitemap files in '" . $self->dir . "' directory" if $self->verbose; - $self->writer( Koha::Sitemapper::Writer->new( sitemapper => $self ) ); - my $rs = Koha::Biblios->search( $filter, { columns => [ qw/biblionumber timestamp/ ] }); + try { + $self->writer( Koha::Sitemapper::Writer->new( sitemapper => $self ) ); + my $rs = Koha::Biblios->search( $filter, { columns => [ qw/biblionumber timestamp/ ] }); - while ( $self->process($rs) ) { - say "..... ", $self->count - if $self->verbose && $self->count % 10000 == 0; + while ( $self->process($rs) ) { + say "..... ", $self->count + if $self->verbose && $self->count % 10000 == 0; + } } + catch { + if ( $_->isa('DBIx::Class::Exception') ) { + warn $_->{msg}; + } + }; } -- 2.30.2