Bugzilla – Attachment 168439 Details for
Bug 36942
Throw an exception if a KBART file can't be read
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36942: Use an exception for a failed KBART file parse
Bug-36942-Use-an-exception-for-a-failed-KBART-file.patch (text/plain), 2.78 KB, created by
Matt Blenkinsop
on 2024-07-03 11:19:38 UTC
(
hide
)
Description:
Bug 36942: Use an exception for a failed KBART file parse
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-07-03 11:19:38 UTC
Size:
2.78 KB
patch
obsolete
>From 27c064e671320b03e04418742e46f5380f07e88e Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Wed, 3 Jul 2024 11:17:27 +0000 >Subject: [PATCH] Bug 36942: Use an exception for a failed KBART file parse > >Test plan: >1) prove t/db_dependent/Koha/BackgroundJob/ImportKBARTFile.t >--- > Koha/ERM/EHoldings/Title.pm | 3 +-- > Koha/Exceptions.pm | 5 +++++ > t/db_dependent/Koha/BackgroundJob/ImportKBARTFile.t | 7 +++---- > 3 files changed, 9 insertions(+), 6 deletions(-) > >diff --git a/Koha/ERM/EHoldings/Title.pm b/Koha/ERM/EHoldings/Title.pm >index 73e4d53846..60e65d71db 100644 >--- a/Koha/ERM/EHoldings/Title.pm >+++ b/Koha/ERM/EHoldings/Title.pm >@@ -137,8 +137,7 @@ sub read_file { > unless ( $csv->eof() ) { > my ( $cde, $str, $pos ) = $csv->error_diag(); > my $error = $cde ? "$cde, $str, $pos" : ""; >- warn $error if $error; >- return ( $column_headers, $lines, $error ); >+ Koha::Exceptions::FileNotParsed->throw( filename => $file->{filename}, error => $error ); > } > > return ( $column_headers, $lines ); >diff --git a/Koha/Exceptions.pm b/Koha/Exceptions.pm >index 0d5a1ac1ed..1415c05fc7 100644 >--- a/Koha/Exceptions.pm >+++ b/Koha/Exceptions.pm >@@ -20,6 +20,11 @@ use Exception::Class ( > description => 'File not found', > fields => ['filename'], > }, >+ 'Koha::Exceptions::FileNotParsed' => { >+ isa => 'Koha::Exception', >+ description => 'File could not be parsed', >+ fields => [ 'filename', 'error' ], >+ }, > 'Koha::Exceptions::InvalidStatus' => { > isa => 'Koha::Exception', > description => 'The current status is not valid in context', >diff --git a/t/db_dependent/Koha/BackgroundJob/ImportKBARTFile.t b/t/db_dependent/Koha/BackgroundJob/ImportKBARTFile.t >index c018a9414b..0b8cdf6894 100755 >--- a/t/db_dependent/Koha/BackgroundJob/ImportKBARTFile.t >+++ b/t/db_dependent/Koha/BackgroundJob/ImportKBARTFile.t >@@ -20,6 +20,7 @@ use Modern::Perl; > use Test::More tests => 8; > use Test::MockModule; > use Test::Warn; >+use Test::Exception; > > use Koha::Database; > use Koha::BackgroundJobs; >@@ -135,10 +136,8 @@ Nature Plants,,2055-0278,2015-01,1,1,,,,https://www.nature.com/nplants,,4aaa7,,f > Nature Astronomy,,2397-3366,2017-01,1,1,,,,https://www.nature.com/natastron,,4bbb0,,fulltext,Hybrid (Open Choice),Nature Publishing Group UK,serial,,,,,,,,P" > ) > }; >- warning_is { >- Koha::ERM::EHoldings::Title::read_file($file2); >- } >- '2023, EIQ - QUO character not allowed, 157', 'Error message correctly reported'; >+ >+ throws_ok { Koha::ERM::EHoldings::Title::read_file($file2); } 'Koha::Exceptions::FileNotParsed'; > }; > > subtest '_create_title_hash_from_line_data' => sub { >-- >2.39.3 (Apple Git-146)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36942
: 168439