Bugzilla – Attachment 178616 Details for
Bug 39191
Add a `format` param to Koha::Exceptions::ArticleRequest::WrongFormat
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39191: Add `format` parameter to Koha::Exceptions::ArticleRequest::WrongFormat
Bug-39191-Add-format-parameter-to-KohaExceptionsAr.patch (text/plain), 2.84 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-02-24 17:39:37 UTC
(
hide
)
Description:
Bug 39191: Add `format` parameter to Koha::Exceptions::ArticleRequest::WrongFormat
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-02-24 17:39:37 UTC
Size:
2.84 KB
patch
obsolete
>From e87417d09af1c885f8e422a999dd51e3b3b30e73 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 24 Feb 2025 17:35:13 +0000 >Subject: [PATCH] Bug 39191: Add `format` parameter to > Koha::Exceptions::ArticleRequest::WrongFormat > >This patch just adds a new parameter so any exception consumer or even >the logs contain more information about the context in which the >exception was thrown. This would be useful debugging issues. > >No behavior change in Koha. > >To test: >1. Run: > $ ktd --shell > k$ prove t/db_dependent/Koha/ArticleRequest.t >=> SUCCESS: Tests pass! >2. Apply this patch >3. Repeat 2 >=> SUCCESS: Tests pass! >4. Sign off :-D >--- > Koha/ArticleRequest.pm | 2 +- > Koha/Exceptions/ArticleRequest.pm | 3 ++- > t/db_dependent/Koha/ArticleRequest.t | 3 ++- > 3 files changed, 5 insertions(+), 3 deletions(-) > >diff --git a/Koha/ArticleRequest.pm b/Koha/ArticleRequest.pm >index 33421fbb3a1..f1d5968754f 100644 >--- a/Koha/ArticleRequest.pm >+++ b/Koha/ArticleRequest.pm >@@ -269,7 +269,7 @@ sub store { > $self->created_on( dt_from_string() ); > } > >- Koha::Exceptions::ArticleRequest::WrongFormat->throw >+ Koha::Exceptions::ArticleRequest::WrongFormat->throw( format => $self->format ) > unless grep { $_ eq $self->format } @{ C4::Context->multivalue_preference('ArticleRequestsSupportedFormats') }; > > return $self->SUPER::store; >diff --git a/Koha/Exceptions/ArticleRequest.pm b/Koha/Exceptions/ArticleRequest.pm >index 9e016a6f7e1..ad46187a411 100644 >--- a/Koha/Exceptions/ArticleRequest.pm >+++ b/Koha/Exceptions/ArticleRequest.pm >@@ -29,7 +29,8 @@ use Exception::Class ( > }, > 'Koha::Exceptions::ArticleRequest::WrongFormat' => { > isa => 'Koha::Exceptions::ArticleRequest', >- description => 'Passed format is not locally supported' >+ description => 'Passed format is not locally supported', >+ fields => ['format'], > }, > ); > >diff --git a/t/db_dependent/Koha/ArticleRequest.t b/t/db_dependent/Koha/ArticleRequest.t >index 3de1619b069..e28b237e746 100755 >--- a/t/db_dependent/Koha/ArticleRequest.t >+++ b/t/db_dependent/Koha/ArticleRequest.t >@@ -223,13 +223,14 @@ subtest 'cancel() tests' => sub { > }; > > subtest 'store' => sub { >- plan tests => 2; >+ plan tests => 3; > $schema->storage->txn_begin; > > t::lib::Mocks::mock_preference( 'ArticleRequestsSupportedFormats', 'SCAN' ); > my $ar = $builder->build_object( { class => 'Koha::ArticleRequests', value => { format => 'PHOTOCOPY' } } ); > throws_ok { $ar->format('test')->store } 'Koha::Exceptions::ArticleRequest::WrongFormat', > 'Format not supported'; >+ is( $@->format, 'test', 'Passed format returned with the exception' ); > t::lib::Mocks::mock_preference( 'ArticleRequestsSupportedFormats', 'SCAN|PHOTOCOPY|ELSE' ); > lives_ok { $ar->format('PHOTOCOPY')->store } 'Now we do support it'; > >-- >2.48.1
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 39191
:
178616
|
180397