Bugzilla – Attachment 181906 Details for
Bug 39823
SUSHI harvest fails to display error if the provider's response does not contain Severity
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39823: Identify error messages based on code
Bug-39823-Identify-error-messages-based-on-code.patch (text/plain), 2.67 KB, created by
Pedro Amorim
on 2025-05-05 10:34:32 UTC
(
hide
)
Description:
Bug 39823: Identify error messages based on code
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2025-05-05 10:34:32 UTC
Size:
2.67 KB
patch
obsolete
>From 6cf48173c760047aae6928e47f1313993730c4ed Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Mon, 5 May 2025 10:28:43 +0000 >Subject: [PATCH] Bug 39823: Identify error messages based on code > >Even if severity does not exist. Additionally, only add severity to message if it exists. > >Test plan: >1) Apply tests patches. Run tests (they should fail): >prove t/db_dependent/Koha/BackgroundJobs/ErmSushiHarvester.t >2) Apply this patch and run tests again (they should pass this time). > >UI test: >1) Create a new data provider linked to Gale Cengage, service url: >https://api.siqcloud.online/counterapi/r51 >2) Add report release 5, customer id: '123', requestor id: '123', report types: 'TR_J1' >3) Run a report for this data provider, from Feb 2025 to Apr 2025. Notice that before applying patches, the job report results in a red bar with no error message. >4) Apply patches, repeat 3. Notice it now results in a nice error message. >--- > Koha/ERM/EUsage/UsageDataProvider.pm | 22 ++++++++++++++++++++-- > 1 file changed, 20 insertions(+), 2 deletions(-) > >diff --git a/Koha/ERM/EUsage/UsageDataProvider.pm b/Koha/ERM/EUsage/UsageDataProvider.pm >index cdb82e31d5f..b7acc76ab53 100644 >--- a/Koha/ERM/EUsage/UsageDataProvider.pm >+++ b/Koha/ERM/EUsage/UsageDataProvider.pm >@@ -443,6 +443,24 @@ sub _check_trailing_character { > return $url; > } > >+=head3 sushi_code_is_error >+ >+ my $is_error = $self->sushi_code_is_error($code); >+ >+Determines if a given SUSHI response code is considered an error. Codes greater than 1000 are generally errors unless they are in the list of known warning codes, in which case they are treated as non-errors. Docs at: >+https://cop5.projectcounter.org/en/5.0.2/appendices/f-handling-errors-and-exceptions.html >+ >+=cut >+ >+sub _sushi_code_is_error { >+ my ($code) = @_; >+ >+ return 0 unless $code; >+ >+ my @warning_codes = ( 1011, 3032, 3040, 3050, 3060, 3061, 3062, 3070 ); >+ return 1 if $code > 1000 && !grep { $_ == $code } @warning_codes; >+} >+ > =head3 _sushi_errors > > Checks and handles possible errors in the SUSHI response >@@ -457,12 +475,12 @@ sub _sushi_errors { > my $message = $decoded_response->{Message} // $decoded_response->{message}; > my $code = $decoded_response->{Code} // $decoded_response->{code}; > >- if ($severity) { >+ if ( $severity || _sushi_code_is_error($code) ) { > $self->{job_callbacks}->{add_message_callback}->( > { > type => 'error', > code => $code, >- message => $severity . ' - ' . $message, >+ message => ( $severity ? "$severity - " : '' ) . $message, > } > ) if $self->{job_callbacks}; > return 1; >-- >2.39.5
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 39823
:
181904
|
181905
|
181906
|
182121
|
182122
|
182123
|
182816
|
182817
|
182818