From 15d4aa2b4dc06ed628f11eb263d90be35d8a8e06 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 18 Feb 2021 10:48:41 +0000 Subject: [PATCH] Bug 26618: Improve Exception Class Names Signed-off-by: Jonathan Druart --- C4/RotatingCollections.pm | 2 +- Koha/Exceptions/Item/Transfer.pm | 12 ++++++------ Koha/Item.pm | 2 +- Koha/Item/Transfer.pm | 6 +++--- Koha/StockRotationItem.pm | 2 +- t/db_dependent/Koha/Item.t | 2 +- t/db_dependent/Koha/Item/Transfer.t | 6 +++--- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/C4/RotatingCollections.pm b/C4/RotatingCollections.pm index b7a7bb3a74..5ee1982123 100644 --- a/C4/RotatingCollections.pm +++ b/C4/RotatingCollections.pm @@ -457,7 +457,7 @@ sub TransferCollection { ); # Request transfer } catch { - if ( $_->isa('Koha::Exceptions::Item::Transfer::Found') ) { + if ( $_->isa('Koha::Exceptions::Item::Transfer::InQueue') ) { my $exception = $_; my $found_transfer = $_->transfer; if ( $found_transfer->in_transit diff --git a/Koha/Exceptions/Item/Transfer.pm b/Koha/Exceptions/Item/Transfer.pm index 28429d9e01..a836714dbc 100644 --- a/Koha/Exceptions/Item/Transfer.pm +++ b/Koha/Exceptions/Item/Transfer.pm @@ -22,7 +22,7 @@ use Exception::Class ( 'Koha::Exceptions::Item::Transfer' => { description => 'Something went wrong' }, - 'Koha::Exceptions::Item::Transfer::Found' => { + 'Koha::Exceptions::Item::Transfer::InQueue' => { isa => 'Koha::Exceptions::Item::Transfer', description => "Active item transfer already exists", fields => ['transfer'] @@ -31,11 +31,11 @@ use Exception::Class ( isa => 'Koha::Exceptions::Item::Transfer', description => "Transfer not allowed" }, - 'Koha::Exceptions::Item::Transfer::Out' => { + 'Koha::Exceptions::Item::Transfer::OnLoan' => { isa => 'Koha::Exceptions::Item::Transfer', description => "Transfer item is currently checked out" }, - 'Koha::Exceptions::Item::Transfer::Transit' => { + 'Koha::Exceptions::Item::Transfer::InTransit' => { isa => 'Koha::Exceptions::Item::Transfer', description => "Transfer item is currently in transit" } @@ -51,7 +51,7 @@ Koha::Exceptions::Item::Transfer - Base class for Transfer exceptions Generic Item::Transfer exception -=head2 Koha::Exceptions::Item::Transfer::Found +=head2 Koha::Exceptions::Item::Transfer::InQueue Exception to be used when an active item transfer prevents a transfer action. @@ -59,11 +59,11 @@ Exception to be used when an active item transfer prevents a transfer action. Exception to be used when transfer limits prevent a transfer action. -=head2 Koha::Exceptions::Item::Transfer::Out +=head2 Koha::Exceptions::Item::Transfer::OnLoan Exception to be used when an active checkout prevents a transfer action. -=head2 Koha::Exceptions::Item::Transfer::Transit +=head2 Koha::Exceptions::Item::Transfer::InTransit Exception to be used when an in transit transfer prevents a transfer action. diff --git a/Koha/Item.pm b/Koha/Item.pm index 0794974b1a..7bbc87b95b 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -444,7 +444,7 @@ sub request_transfer { || $self->can_be_transferred( { to => $params->{to} } ) ); my $request = $self->get_transfer; - Koha::Exceptions::Item::Transfer::Found->throw( transfer => $request ) + Koha::Exceptions::Item::Transfer::InQueue->throw( transfer => $request ) if ( $request && !$params->{enqueue} && !$params->{replace} ); $request->cancel( { reason => $params->{reason}, force => 1 } ) diff --git a/Koha/Item/Transfer.pm b/Koha/Item/Transfer.pm index c9e3206b53..8f4284f53a 100644 --- a/Koha/Item/Transfer.pm +++ b/Koha/Item/Transfer.pm @@ -63,7 +63,7 @@ sub transit { my ($self) = @_; # Throw exception if item is still checked out - Koha::Exceptions::Item::Transfer::Out->throw() if ( $self->item->checkout ); + Koha::Exceptions::Item::Transfer::OnLoan->throw() if ( $self->item->checkout ); # Remove the 'shelving cart' location status if it is being used (Bug 3701) CartToShelf( $self->item->itemnumber ) @@ -107,7 +107,7 @@ sub receive { my ($self) = @_; # Throw exception if item is checked out - Koha::Exceptions::Item::Transfer::Out->throw() if ($self->item->checkout); + Koha::Exceptions::Item::Transfer::OnLoan->throw() if ($self->item->checkout); # Update the arrived date $self->set({ datearrived => dt_from_string })->store; @@ -132,7 +132,7 @@ sub cancel { unless defined($params->{reason}); # Throw exception if item is in transit already - Koha::Exceptions::Item::Transfer::Transit->throw() if ( !$params->{force} && $self->in_transit ); + Koha::Exceptions::Item::Transfer::InTransit->throw() if ( !$params->{force} && $self->in_transit ); # Update the cancelled date $self->set( diff --git a/Koha/StockRotationItem.pm b/Koha/StockRotationItem.pm index 6c6d99cd43..d2e91e828b 100644 --- a/Koha/StockRotationItem.pm +++ b/Koha/StockRotationItem.pm @@ -242,7 +242,7 @@ sub advance { ); # Add transfer } catch { - if ( $_->isa('Koha::Exceptions::Item::Transfer::Found') ) { + if ( $_->isa('Koha::Exceptions::Item::Transfer::InQueue') ) { my $exception = $_; my $found_transfer = $_->transfer; if ( $found_transfer->in_transit diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index 8858e071fa..06a9a6ef52 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -483,7 +483,7 @@ subtest 'request_transfer' => sub { # Transfer already in progress throws_ok { $item->request_transfer( { to => $library2, reason => 'Manual' } ) } - 'Koha::Exceptions::Item::Transfer::Found', + 'Koha::Exceptions::Item::Transfer::InQueue', 'Exception thrown if transfer is already in progress'; my $exception = $@; diff --git a/t/db_dependent/Koha/Item/Transfer.t b/t/db_dependent/Koha/Item/Transfer.t index ac782e28fb..c2bdd2cb7d 100755 --- a/t/db_dependent/Koha/Item/Transfer.t +++ b/t/db_dependent/Koha/Item/Transfer.t @@ -92,7 +92,7 @@ subtest 'transit tests' => sub { is( ref($checkout), 'Koha::Checkout', 'Mock checkout added' ); throws_ok { $transfer->transit() } - 'Koha::Exceptions::Item::Transfer::Out', + 'Koha::Exceptions::Item::Transfer::OnLoan', 'Exception thrown if item is checked out'; $checkout->delete; @@ -155,7 +155,7 @@ subtest 'receive tests' => sub { is( ref($checkout), 'Koha::Checkout', 'Mock checkout added' ); throws_ok { $transfer->receive() } - 'Koha::Exceptions::Item::Transfer::Out', + 'Koha::Exceptions::Item::Transfer::OnLoan', 'Exception thrown if item is checked out'; $checkout->delete; @@ -246,7 +246,7 @@ subtest 'cancel tests' => sub { # Item in transit should result in failure throws_ok { $transfer->cancel({ reason => $cancellation_reason }) } - 'Koha::Exceptions::Item::Transfer::Transit', + 'Koha::Exceptions::Item::Transfer::InTransit', 'Exception thrown if item is in transit'; $transfer->cancel({ reason => $cancellation_reason, force => 1}); -- 2.39.5