Bug 26618: Improve Exception Class Names

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Martin Renvoize 2021-02-18 10:48:41 +00:00 committed by Jonathan Druart
parent 138212f856
commit 15d4aa2b4d
7 changed files with 16 additions and 16 deletions

View File

@ -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

View File

@ -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.

View File

@ -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 } )

View File

@ -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(

View File

@ -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

View File

@ -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 = $@;

View File

@ -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});