From 2b9fae544575a4386748238212c0ca62854af30e Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 31 Jan 2022 11:02:41 -0300 Subject: [PATCH] Bug 29857: Rename base class as Koha::Exception Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers --- Koha/Acquisition/Orders.pm | 2 +- Koha/BackgroundJob.pm | 6 ++-- Koha/Checkout.pm | 4 +-- Koha/{Exceptions => }/Exception.pm | 5 ++- Koha/Exceptions.pm | 35 ++++++++++--------- Koha/Exceptions/Account.pm | 4 +-- Koha/Exceptions/Acquisition/Basket.pm | 4 +-- Koha/Exceptions/ArticleRequest.pm | 4 +-- Koha/Exceptions/Authentication.pm | 4 +-- Koha/Exceptions/Authorization.pm | 4 +-- Koha/Exceptions/Checkout.pm | 4 +-- Koha/Exceptions/Checkouts/ReturnClaims.pm | 4 +-- Koha/Exceptions/ClubHold.pm | 4 +-- Koha/Exceptions/Config.pm | 4 +-- Koha/Exceptions/Elasticsearch.pm | 4 +-- Koha/Exceptions/Hold.pm | 4 +-- Koha/Exceptions/Ill.pm | 4 +-- Koha/Exceptions/Item/Transfer.pm | 4 +-- Koha/Exceptions/Library.pm | 4 +-- Koha/Exceptions/MarcOverlayRule.pm | 4 +-- Koha/Exceptions/Metadata.pm | 4 +-- Koha/Exceptions/Object.pm | 4 +-- Koha/Exceptions/Password.pm | 4 +-- Koha/Exceptions/Patron.pm | 4 +-- Koha/Exceptions/Patron/Attribute.pm | 4 +-- Koha/Exceptions/Patron/Attribute/Type.pm | 4 +-- Koha/Exceptions/Patron/Modification.pm | 4 +-- Koha/Exceptions/Patron/Relationship.pm | 4 +-- Koha/Exceptions/Plugin.pm | 4 +-- Koha/Exceptions/Token.pm | 4 +-- Koha/Exceptions/TransferLimit.pm | 4 +-- Koha/Object.pm | 2 +- Koha/REST/V1/Patrons.pm | 4 +-- Koha/Script.pm | 6 ++-- Koha/SearchEngine/Elasticsearch/Indexer.pm | 4 +-- admin/smart-rules.pl | 6 ++-- .../Koha/BackgroundJobs/BatchUpdateBiblio.t | 4 +-- t/db_dependent/Koha/Biblio.t | 4 +-- t/db_dependent/Koha/Object.t | 2 +- t/db_dependent/api/v1/unhandled_exceptions.t | 2 +- t/lib/plugins/Koha/Plugin/Test.pm | 24 ++++++------- .../Koha/Plugin/TestItemBarcodeTransform.pm | 4 +-- tools/batchMod.pl | 2 +- 43 files changed, 110 insertions(+), 110 deletions(-) rename Koha/{Exceptions => }/Exception.pm (78%) diff --git a/Koha/Acquisition/Orders.pm b/Koha/Acquisition/Orders.pm index b2496260a9..a646dac802 100644 --- a/Koha/Acquisition/Orders.pm +++ b/Koha/Acquisition/Orders.pm @@ -22,7 +22,7 @@ use Koha::Database; use Koha::DateUtils qw( dt_from_string ); use Koha::Acquisition::Order; -use Koha::Exceptions::Exception; +use Koha::Exception; use base qw(Koha::Objects); diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm index cb8a71fb04..9f3be705e9 100644 --- a/Koha/BackgroundJob.pm +++ b/Koha/BackgroundJob.pm @@ -126,9 +126,9 @@ sub enqueue { # Picking a random id (memcached_namespace) from the config my $namespace = C4::Context->config('memcached_namespace'); $conn->send_with_receipt( { destination => sprintf("/queue/%s-%s", $namespace, $job_type), body => $json_args } ) - or Koha::Exceptions::Exception->throw('Job has not been enqueued'); + or Koha::Exception->throw('Job has not been enqueued'); } catch { - if ( ref($_) eq 'Koha::Exceptions::Exception' ) { + if ( ref($_) eq 'Koha::Exception' ) { $_->rethrow; } else { warn sprintf "The job has not been sent to the message broker: (%s)", $_; @@ -236,7 +236,7 @@ sub _derived_class { my $class = $self->type_to_class_mapping->{$job_type}; - Koha::Exceptions::Exception->throw($job_type . ' is not a valid job_type') + Koha::Exception->throw($job_type . ' is not a valid job_type') unless $class; eval "require $class"; diff --git a/Koha/Checkout.pm b/Koha/Checkout.pm index 6dd98ca3e2..34f0098d06 100644 --- a/Koha/Checkout.pm +++ b/Koha/Checkout.pm @@ -199,12 +199,12 @@ sub claim_returned { ); } catch { - if ( $_->isa('Koha::Exceptions::Exception') ) { + if ( $_->isa('Koha::Exception') ) { $_->rethrow(); } else { # ? - Koha::Exceptions::Exception->throw( "Unhandled exception" ); + Koha::Exception->throw( "Unhandled exception" ); } }; } diff --git a/Koha/Exceptions/Exception.pm b/Koha/Exception.pm similarity index 78% rename from Koha/Exceptions/Exception.pm rename to Koha/Exception.pm index 5dfe20f7ef..69702d2936 100644 --- a/Koha/Exceptions/Exception.pm +++ b/Koha/Exception.pm @@ -1,10 +1,9 @@ -package Koha::Exceptions::Exception; +package Koha::Exception; use Modern::Perl; -# Looks like this class should be more Koha::Exception::Base; use Exception::Class ( - 'Koha::Exceptions::Exception' => { + 'Koha::Exception' => { description => "Something went wrong!" }, ); diff --git a/Koha/Exceptions.pm b/Koha/Exceptions.pm index eec3baaa14..5cb8d5c38b 100644 --- a/Koha/Exceptions.pm +++ b/Koha/Exceptions.pm @@ -1,57 +1,58 @@ package Koha::Exceptions; use Modern::Perl; -use Koha::Exceptions::Exception; + +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::BadParameter' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description => 'A bad parameter was given', fields => ['parameter'], }, 'Koha::Exceptions::DuplicateObject' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description => 'Same object already exists', }, 'Koha::Exceptions::ObjectNotFound' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description => 'The required object doesn\'t exist', }, 'Koha::Exceptions::ObjectNotCreated' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description => 'The object have not been created', }, 'Koha::Exceptions::CannotDeleteDefault' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description => 'The default value cannot be deleted' }, 'Koha::Exceptions::MissingParameter' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description => 'A required parameter is missing' }, 'Koha::Exceptions::ParameterTooHigh' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description => 'A passed parameter value is too high' }, 'Koha::Exceptions::NoChanges' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description => 'No changes were made', }, 'Koha::Exceptions::WrongParameter' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description => 'One or more parameters are wrong', }, 'Koha::Exceptions::NoPermission' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description => 'You do not have permission for this action', }, 'Koha::Exceptions::CannotAddLibraryLimit' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description => 'General problem adding a library limit' }, 'Koha::Exceptions::UnderMaintenance' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description => 'Koha is under maintenance.' }, # Virtualshelves exceptions @@ -60,19 +61,19 @@ use Exception::Class ( description => "Duplicate shelf object", }, 'Koha::Exceptions::Virtualshelves::InvalidInviteKey' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description => 'Invalid key on accepting the share', }, 'Koha::Exceptions::Virtualshelves::InvalidKeyOnSharing' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description=> 'Invalid key on sharing a shelf', }, 'Koha::Exceptions::Virtualshelves::ShareHasExpired' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description=> 'Cannot share this shelf, the share has expired', }, 'Koha::Exceptions::Virtualshelves::UseDbAdminAccount' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', description => "Invalid use of database administrator account", } ); diff --git a/Koha/Exceptions/Account.pm b/Koha/Exceptions/Account.pm index a34c00ee3c..e22d5ee521 100644 --- a/Koha/Exceptions/Account.pm +++ b/Koha/Exceptions/Account.pm @@ -17,12 +17,12 @@ package Koha::Exceptions::Account; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Account' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Account::IsNotCredit' => { isa => 'Koha::Exceptions::Account', diff --git a/Koha/Exceptions/Acquisition/Basket.pm b/Koha/Exceptions/Acquisition/Basket.pm index 52fb45ab30..3737e42e36 100644 --- a/Koha/Exceptions/Acquisition/Basket.pm +++ b/Koha/Exceptions/Acquisition/Basket.pm @@ -17,12 +17,12 @@ package Koha::Exceptions::Acquisition::Basket; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Acquisition::Basket' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Acquisition::Basket::AlreadyClosed' => { isa => 'Koha::Exceptions::Acquisition::Basket', diff --git a/Koha/Exceptions/ArticleRequest.pm b/Koha/Exceptions/ArticleRequest.pm index 99e4059929..cfb5baa55e 100644 --- a/Koha/Exceptions/ArticleRequest.pm +++ b/Koha/Exceptions/ArticleRequest.pm @@ -17,11 +17,11 @@ package Koha::Exceptions::ArticleRequest; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::ArticleRequest' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::ArticleRequest::LimitReached' => { isa => 'Koha::Exceptions::ArticleRequest', diff --git a/Koha/Exceptions/Authentication.pm b/Koha/Exceptions/Authentication.pm index e8c3227523..6bd83f48a0 100644 --- a/Koha/Exceptions/Authentication.pm +++ b/Koha/Exceptions/Authentication.pm @@ -2,12 +2,12 @@ package Koha::Exceptions::Authentication; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Authentication' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Authentication::Required' => { isa => 'Koha::Exceptions::Authentication', diff --git a/Koha/Exceptions/Authorization.pm b/Koha/Exceptions/Authorization.pm index 1b070df1d0..fde34bc178 100644 --- a/Koha/Exceptions/Authorization.pm +++ b/Koha/Exceptions/Authorization.pm @@ -2,12 +2,12 @@ package Koha::Exceptions::Authorization; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Authorization' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Authorization::Unauthorized' => { isa => 'Koha::Exceptions::Authorization', diff --git a/Koha/Exceptions/Checkout.pm b/Koha/Exceptions/Checkout.pm index f6ceb038fc..e65f455573 100644 --- a/Koha/Exceptions/Checkout.pm +++ b/Koha/Exceptions/Checkout.pm @@ -2,11 +2,11 @@ package Koha::Exceptions::Checkout; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Checkout' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Checkout::FailedRenewal' => { isa => 'Koha::Exceptions::Checkout', diff --git a/Koha/Exceptions/Checkouts/ReturnClaims.pm b/Koha/Exceptions/Checkouts/ReturnClaims.pm index d1a63f8037..d4d35b1711 100644 --- a/Koha/Exceptions/Checkouts/ReturnClaims.pm +++ b/Koha/Exceptions/Checkouts/ReturnClaims.pm @@ -17,11 +17,11 @@ package Koha::Exceptions::Checkouts::ReturnClaims; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Checkouts::ReturnClaims' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Checkouts::ReturnClaims::NoCreatedBy' => { isa => 'Koha::Exceptions::Checkouts::ReturnClaims', diff --git a/Koha/Exceptions/ClubHold.pm b/Koha/Exceptions/ClubHold.pm index d7ca3bf914..a7f0c2498c 100644 --- a/Koha/Exceptions/ClubHold.pm +++ b/Koha/Exceptions/ClubHold.pm @@ -2,11 +2,11 @@ package Koha::Exceptions::ClubHold; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::ClubHold' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::ClubHold::NoPatrons' => { isa => 'Koha::Exceptions::ClubHold', diff --git a/Koha/Exceptions/Config.pm b/Koha/Exceptions/Config.pm index 2a9488eb62..06a85f4b64 100644 --- a/Koha/Exceptions/Config.pm +++ b/Koha/Exceptions/Config.pm @@ -2,12 +2,12 @@ package Koha::Exceptions::Config; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Config' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Config::MissingEntry' => { isa => 'Koha::Exceptions::Config', diff --git a/Koha/Exceptions/Elasticsearch.pm b/Koha/Exceptions/Elasticsearch.pm index 37d993fcc6..227fd65dcc 100644 --- a/Koha/Exceptions/Elasticsearch.pm +++ b/Koha/Exceptions/Elasticsearch.pm @@ -17,12 +17,12 @@ package Koha::Exceptions::Elasticsearch; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Elasticsearch' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Elasticsearch::BadResponse' => { isa => 'Koha::Exceptions::Elasticsearch', diff --git a/Koha/Exceptions/Hold.pm b/Koha/Exceptions/Hold.pm index 65d7b9d9a9..8538963b96 100644 --- a/Koha/Exceptions/Hold.pm +++ b/Koha/Exceptions/Hold.pm @@ -17,11 +17,11 @@ package Koha::Exceptions::Hold; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Hold' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Hold::CannotSuspendFound' => { isa => 'Koha::Exceptions::Hold', diff --git a/Koha/Exceptions/Ill.pm b/Koha/Exceptions/Ill.pm index 66d5adcdd9..34e3c62223 100644 --- a/Koha/Exceptions/Ill.pm +++ b/Koha/Exceptions/Ill.pm @@ -17,12 +17,12 @@ package Koha::Exceptions::Ill; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Ill' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Ill::InvalidBackendId' => { isa => 'Koha::Exceptions::Ill', diff --git a/Koha/Exceptions/Item/Transfer.pm b/Koha/Exceptions/Item/Transfer.pm index 0d8aea59c7..6842b2806e 100644 --- a/Koha/Exceptions/Item/Transfer.pm +++ b/Koha/Exceptions/Item/Transfer.pm @@ -17,12 +17,12 @@ package Koha::Exceptions::Item::Transfer; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Item::Transfer' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Item::Transfer::InQueue' => { isa => 'Koha::Exceptions::Item::Transfer', diff --git a/Koha/Exceptions/Library.pm b/Koha/Exceptions/Library.pm index 06ee38cf0d..9009254773 100644 --- a/Koha/Exceptions/Library.pm +++ b/Koha/Exceptions/Library.pm @@ -2,12 +2,12 @@ package Koha::Exceptions::Library; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Library::Exception' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Library::NotFound' => { diff --git a/Koha/Exceptions/MarcOverlayRule.pm b/Koha/Exceptions/MarcOverlayRule.pm index 799469041f..3b69916e4c 100644 --- a/Koha/Exceptions/MarcOverlayRule.pm +++ b/Koha/Exceptions/MarcOverlayRule.pm @@ -17,12 +17,12 @@ package Koha::Exceptions::MarcOverlayRule; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::MarcOverlayRule' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::MarcOverlayRule::InvalidTagRegExp' => { isa => 'Koha::Exceptions::MarcOverlayRule', diff --git a/Koha/Exceptions/Metadata.pm b/Koha/Exceptions/Metadata.pm index 683bf9d50d..5cc494013b 100644 --- a/Koha/Exceptions/Metadata.pm +++ b/Koha/Exceptions/Metadata.pm @@ -17,12 +17,12 @@ package Koha::Exceptions::Metadata; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Metadata' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Metadata::Invalid' => { isa => 'Koha::Exceptions::Metadata', diff --git a/Koha/Exceptions/Object.pm b/Koha/Exceptions/Object.pm index 688a97cd5a..dd79cee90c 100644 --- a/Koha/Exceptions/Object.pm +++ b/Koha/Exceptions/Object.pm @@ -17,11 +17,11 @@ package Koha::Exceptions::Object; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Object' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Object::DuplicateID' => { isa => 'Koha::Exceptions::Object', diff --git a/Koha/Exceptions/Password.pm b/Koha/Exceptions/Password.pm index 7219a0092a..803e8a7243 100644 --- a/Koha/Exceptions/Password.pm +++ b/Koha/Exceptions/Password.pm @@ -17,12 +17,12 @@ package Koha::Exceptions::Password; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Password' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Password::Invalid' => { isa => 'Koha::Exceptions::Password', diff --git a/Koha/Exceptions/Patron.pm b/Koha/Exceptions/Patron.pm index 3c7ee9651f..017340a340 100644 --- a/Koha/Exceptions/Patron.pm +++ b/Koha/Exceptions/Patron.pm @@ -2,11 +2,11 @@ package Koha::Exceptions::Patron; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Patron' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Patron::FailedDelete' => { isa => 'Koha::Exceptions::Patron', diff --git a/Koha/Exceptions/Patron/Attribute.pm b/Koha/Exceptions/Patron/Attribute.pm index 32f730f75e..90e7b0e555 100644 --- a/Koha/Exceptions/Patron/Attribute.pm +++ b/Koha/Exceptions/Patron/Attribute.pm @@ -2,12 +2,12 @@ package Koha::Exceptions::Patron::Attribute; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Patron::Attribute' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Patron::Attribute::InvalidType' => { isa => 'Koha::Exceptions::Patron::Attribute', diff --git a/Koha/Exceptions/Patron/Attribute/Type.pm b/Koha/Exceptions/Patron/Attribute/Type.pm index 11a3b577d1..2cb29f26b8 100644 --- a/Koha/Exceptions/Patron/Attribute/Type.pm +++ b/Koha/Exceptions/Patron/Attribute/Type.pm @@ -2,12 +2,12 @@ package Koha::Exceptions::Patron::Attribute::Type; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Patron::Attribute::Type' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Patron::Attribute::Type::CannotChangeProperty' => { isa => 'Koha::Exceptions::Patron::Attribute::Type', diff --git a/Koha/Exceptions/Patron/Modification.pm b/Koha/Exceptions/Patron/Modification.pm index 790c930d2d..9dc9064ddb 100644 --- a/Koha/Exceptions/Patron/Modification.pm +++ b/Koha/Exceptions/Patron/Modification.pm @@ -2,12 +2,12 @@ package Koha::Exceptions::Patron::Modification; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Patron::Modification' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Patron::Modification::DuplicateVerificationToken' => { isa => 'Koha::Exceptions::Patron::Modification', diff --git a/Koha/Exceptions/Patron/Relationship.pm b/Koha/Exceptions/Patron/Relationship.pm index 318e13d546..616ad830c7 100644 --- a/Koha/Exceptions/Patron/Relationship.pm +++ b/Koha/Exceptions/Patron/Relationship.pm @@ -17,12 +17,12 @@ package Koha::Exceptions::Patron::Relationship; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Patron::Relationship' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Patron::Relationship::DuplicateRelationship' => { isa => 'Koha::Exceptions::Patron::Relationship', diff --git a/Koha/Exceptions/Plugin.pm b/Koha/Exceptions/Plugin.pm index b10525e7fe..2dd7e9b3b4 100644 --- a/Koha/Exceptions/Plugin.pm +++ b/Koha/Exceptions/Plugin.pm @@ -17,11 +17,11 @@ package Koha::Exceptions::Plugin; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Plugin' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Plugin::ForbiddenAction' => { isa => 'Koha::Exceptions::Plugin', diff --git a/Koha/Exceptions/Token.pm b/Koha/Exceptions/Token.pm index 5f024feb07..c7fe147369 100644 --- a/Koha/Exceptions/Token.pm +++ b/Koha/Exceptions/Token.pm @@ -17,11 +17,11 @@ package Koha::Exceptions::Token; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::Token' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::Token::BadPattern' => { isa => 'Koha::Exceptions::Token', diff --git a/Koha/Exceptions/TransferLimit.pm b/Koha/Exceptions/TransferLimit.pm index 0225b2dbf8..0b1e518f6e 100644 --- a/Koha/Exceptions/TransferLimit.pm +++ b/Koha/Exceptions/TransferLimit.pm @@ -17,12 +17,12 @@ package Koha::Exceptions::TransferLimit; use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Exception::Class ( 'Koha::Exceptions::TransferLimit::Exception' => { - isa => 'Koha::Exceptions::Exception', + isa => 'Koha::Exception', }, 'Koha::Exceptions::TransferLimit::Duplicate' => { diff --git a/Koha/Object.pm b/Koha/Object.pm index f0a0ea8166..ef554d5e56 100644 --- a/Koha/Object.pm +++ b/Koha/Object.pm @@ -907,7 +907,7 @@ sub _handle_to_api_child { if ( defined $child ) { - Koha::Exceptions::Exception->throw( "Asked to embed $curr but its return value doesn't implement to_api" ) + Koha::Exception->throw( "Asked to embed $curr but its return value doesn't implement to_api" ) if defined $next and blessed $child and !$child->can('to_api'); if ( blessed $child ) { diff --git a/Koha/REST/V1/Patrons.pm b/Koha/REST/V1/Patrons.pm index a33ac06d90..43cc666e81 100644 --- a/Koha/REST/V1/Patrons.pm +++ b/Koha/REST/V1/Patrons.pm @@ -338,7 +338,7 @@ sub delete { # Pick the first error, if any my ( $error ) = grep { $_->type eq 'error' } @{ $safe_to_delete->messages }; unless ( $error ) { - Koha::Exceptions::Exception->throw('Koha::Patron->safe_to_delete returned false but carried no error message'); + Koha::Exception->throw('Koha::Patron->safe_to_delete returned false but carried no error message'); } my $error_descriptions = { @@ -357,7 +357,7 @@ sub delete { } ); } else { - Koha::Exceptions::Exception->throw( 'Koha::Patron->safe_to_delete carried an unexpected message: ' . $error->message ); + Koha::Exception->throw( 'Koha::Patron->safe_to_delete carried an unexpected message: ' . $error->message ); } } diff --git a/Koha/Script.pm b/Koha/Script.pm index d9e11ea7d8..f41a45cad7 100644 --- a/Koha/Script.pm +++ b/Koha/Script.pm @@ -40,7 +40,7 @@ use Fcntl qw( LOCK_EX LOCK_NB ); use C4::Context; use Koha::Exceptions; -use Koha::Exceptions::Exception; +use Koha::Exception; sub import { my $class = shift; @@ -136,10 +136,10 @@ sub lock_exec { my $lock_params = ($params->{wait}) ? LOCK_EX : LOCK_EX | LOCK_NB; open my $lock_handle, '>', $self->{lock_file} - or Koha::Exceptions::Exception->throw("Unable to open the lock file ".$self->{lock_file}.": $!"); + or Koha::Exception->throw("Unable to open the lock file ".$self->{lock_file}.": $!"); $self->{lock_handle} = $lock_handle; flock( $lock_handle, $lock_params ) - or Koha::Exceptions::Exception->throw("Unable to acquire the lock ".$self->{lock_file}.": $!"); + or Koha::Exception->throw("Unable to acquire the lock ".$self->{lock_file}.": $!"); } =head2 Internal methods diff --git a/Koha/SearchEngine/Elasticsearch/Indexer.pm b/Koha/SearchEngine/Elasticsearch/Indexer.pm index 0a10832d2e..651a373401 100644 --- a/Koha/SearchEngine/Elasticsearch/Indexer.pm +++ b/Koha/SearchEngine/Elasticsearch/Indexer.pm @@ -226,7 +226,7 @@ sub index_status { INDEX_STATUS_RECREATE_REQUIRED, ) ) { - Koha::Exceptions::Exception->throw("Invalid index status: $status"); + Koha::Exception->throw("Invalid index status: $status"); } C4::Context->set_preference($key, $status); return $status; @@ -263,7 +263,7 @@ sub update_mappings { $self->set_index_status_recreate_required(); my $reason = $_[0]->{vars}->{body}->{error}->{reason}; my $index_name = $self->index_name; - Koha::Exceptions::Exception->throw( + Koha::Exception->throw( error => "Unable to update mappings for index \"$index_name\". Reason was: \"$reason\". Index needs to be recreated and reindexed", ); }; diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index 8f429ec6ae..cd94b5964e 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -22,7 +22,7 @@ use CGI qw ( -utf8 ); use C4::Context; use C4::Output qw( output_html_with_http_headers ); use C4::Auth qw( get_template_and_user ); -use Koha::Exceptions::Exception; +use Koha::Exception; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Database; use Koha::Logger; @@ -462,7 +462,7 @@ elsif ( $op eq "add-open-article-requests-limit" ) { my $categorycode = $input->param('categorycode'); my $open_article_requests_limit = strip_non_numeric( scalar $input->param('open_article_requests_limit') ); - Koha::Exceptions::Exception->throw("No value passed for article request limit") + Koha::Exception->throw("No value passed for article request limit") if not defined $open_article_requests_limit # There is a JS check for that || $open_article_requests_limit eq ''; @@ -536,7 +536,7 @@ elsif ( $op eq "set-article-request-fee" ) { my $category = $input->param('article_request_fee_category'); my $fee = strip_non_numeric( scalar $input->param('article_request_fee') ); - Koha::Exceptions::Exception->throw("No value passed for article request fee") + Koha::Exception->throw("No value passed for article request fee") if not defined $fee # There is a JS check for that || $fee eq ''; diff --git a/t/db_dependent/Koha/BackgroundJobs/BatchUpdateBiblio.t b/t/db_dependent/Koha/BackgroundJobs/BatchUpdateBiblio.t index 8463aef6e1..3d944eeb64 100755 --- a/t/db_dependent/Koha/BackgroundJobs/BatchUpdateBiblio.t +++ b/t/db_dependent/Koha/BackgroundJobs/BatchUpdateBiblio.t @@ -26,7 +26,7 @@ use JSON qw( encode_json decode_json ); use Koha::Database; use Koha::BackgroundJobs; use Koha::BackgroundJob::BatchUpdateBiblio; -use Koha::Exceptions::Exception; +use Koha::Exception; use t::lib::TestBuilder; my $schema = Koha::Database->new->schema; @@ -40,7 +40,7 @@ subtest "Exceptions must be stringified" => sub { my $C4_biblio_module = Test::MockModule->new('C4::Biblio'); $C4_biblio_module->mock( 'ModBiblio', - sub { Koha::Exceptions::Exception->throw("It didn't work"); } ); + sub { Koha::Exception->throw("It didn't work"); } ); my $biblio = $builder->build_sample_biblio; my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t index 01a94dae81..c54ec65fc1 100755 --- a/t/db_dependent/Koha/Biblio.t +++ b/t/db_dependent/Koha/Biblio.t @@ -29,7 +29,7 @@ use Koha::Acquisition::Orders; use Koha::AuthorisedValueCategories; use Koha::AuthorisedValues; use Koha::MarcSubfieldStructures; -use Koha::Exceptions::Exception; +use Koha::Exception; use MARC::Field; use MARC::Record; @@ -541,7 +541,7 @@ subtest 'get_marc_components() tests' => sub { $search_mod->unmock( 'simple_search_compat'); $search_mod->mock( 'simple_search_compat', - sub { Koha::Exceptions::Exception->throw("error searching analytics") } + sub { Koha::Exception->throw("error searching analytics") } ); warning_like { $components = $host_biblio->get_marc_components } qr{^Warning from simple_search_compat: 'error searching analytics'}; diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t index 0f5343005d..f692c183ff 100755 --- a/t/db_dependent/Koha/Object.t +++ b/t/db_dependent/Koha/Object.t @@ -329,7 +329,7 @@ subtest "to_api() tests" => sub { $new_biblio_api = $new_biblio->to_api( { embed => { 'items' => { children => { asd => {} } } } } ); } - 'Koha::Exceptions::Exception', + 'Koha::Exception', "An exception is thrown if a blessed object to embed doesn't implement to_api"; is( diff --git a/t/db_dependent/api/v1/unhandled_exceptions.t b/t/db_dependent/api/v1/unhandled_exceptions.t index 4ebba88b19..61517453ce 100755 --- a/t/db_dependent/api/v1/unhandled_exceptions.t +++ b/t/db_dependent/api/v1/unhandled_exceptions.t @@ -53,7 +53,7 @@ subtest 'unhandled_exception() tests' => sub { my $message = 'delete died'; my $mock_patron = Test::MockModule->new('Koha::Patron'); - $mock_patron->mock( 'delete', sub { Koha::Exceptions::Exception->throw($message); } ); + $mock_patron->mock( 'delete', sub { Koha::Exception->throw($message); } ); my $patron = $builder->build_object({ class => 'Koha::Patrons' }); diff --git a/t/lib/plugins/Koha/Plugin/Test.pm b/t/lib/plugins/Koha/Plugin/Test.pm index c52064c199..c3f5adc122 100644 --- a/t/lib/plugins/Koha/Plugin/Test.pm +++ b/t/lib/plugins/Koha/Plugin/Test.pm @@ -3,7 +3,7 @@ package Koha::Plugin::Test; ## It's good practice to use Modern::Perl use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Koha::Plugins::Tab; use Mojo::JSON qw( decode_json ); @@ -99,13 +99,13 @@ sub item_barcode_transform { if ( Scalar::Util::looks_like_number( $$barcode ) ) { $$barcode = $$barcode * 2 } - Koha::Exceptions::Exception->throw("item_barcode_transform called with parameter: $param"); + Koha::Exception->throw("item_barcode_transform called with parameter: $param"); } sub patron_barcode_transform { my ( $self, $barcode ) = @_; $$barcode //= ''; - Koha::Exceptions::Exception->throw("patron_barcode_transform called with parameter: $$barcode"); + Koha::Exception->throw("patron_barcode_transform called with parameter: $$barcode"); } sub configure { @@ -144,7 +144,7 @@ sub api_namespace { sub after_hold_create { my ( $self, $param ) = @_; - Koha::Exceptions::Exception->throw("after_hold_create called with parameter " . ref($param) ); + Koha::Exception->throw("after_hold_create called with parameter " . ref($param) ); } sub after_biblio_action { @@ -154,10 +154,10 @@ sub after_biblio_action { my $biblio_id = $params->{biblio_id}; if ( $action ne 'delete' ) { - Koha::Exceptions::Exception->throw("after_biblio_action called with action: $action, ref: " . ref($biblio) ); + Koha::Exception->throw("after_biblio_action called with action: $action, ref: " . ref($biblio) ); } else { - Koha::Exceptions::Exception->throw("after_biblio_action called with action: $action, id: $biblio_id") if $biblio_id; + Koha::Exception->throw("after_biblio_action called with action: $action, id: $biblio_id") if $biblio_id; } } @@ -170,12 +170,12 @@ sub after_item_action { if ( $action ne 'delete' ) { my $itemnumber_defined = (defined $item->itemnumber) ? 'yes' : 'no'; my $item_id_defined = (defined $item_id) ? 'yes' : 'no'; - Koha::Exceptions::Exception->throw("after_item_action called with action: $action, ref: " . ref($item) . " ". + Koha::Exception->throw("after_item_action called with action: $action, ref: " . ref($item) . " ". "item_id defined: $item_id_defined ". "itemnumber defined: $itemnumber_defined" ); } else { - Koha::Exceptions::Exception->throw("after_item_action called with action: $action, id: $item_id" ) if $item_id; + Koha::Exception->throw("after_item_action called with action: $action, id: $item_id" ) if $item_id; } } @@ -183,7 +183,7 @@ sub after_authority_action { my ( $self, $params ) = @_; my $action = $params->{action} // q{}; my $id = $params->{authority_id} // 0; - Koha::Exceptions::Exception->throw("after_authority_action called with action: $action, id: $id"); + Koha::Exception->throw("after_authority_action called with action: $action, id: $id"); } sub after_circ_action { @@ -196,13 +196,13 @@ sub after_circ_action { my $type = $payload->{type}; if ( $action eq 'renewal' ) { - Koha::Exceptions::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout)); + Koha::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout)); } elsif ( $action eq 'checkout') { - Koha::Exceptions::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout) . " type: $type"); + Koha::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout) . " type: $type"); } elsif ( $action eq 'checkin' ) { - Koha::Exceptions::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout)); + Koha::Exception->throw("after_circ_action called with action: $action, ref: " . ref($checkout)); } } diff --git a/t/lib/plugins/Koha/Plugin/TestItemBarcodeTransform.pm b/t/lib/plugins/Koha/Plugin/TestItemBarcodeTransform.pm index c653a11c27..220f130e20 100644 --- a/t/lib/plugins/Koha/Plugin/TestItemBarcodeTransform.pm +++ b/t/lib/plugins/Koha/Plugin/TestItemBarcodeTransform.pm @@ -3,7 +3,7 @@ package Koha::Plugin::TestItemBarcodeTransform; ## It's good practice to use Modern::Perl use Modern::Perl; -use Koha::Exceptions::Exception; +use Koha::Exception; use Koha::Plugins::Tab; use Mojo::JSON qw( decode_json ); @@ -38,7 +38,7 @@ sub item_barcode_transform { if ( Scalar::Util::looks_like_number( $$barcode ) ) { $$barcode = $$barcode * 4 } - Koha::Exceptions::Exception->throw("item_barcode_transform called with parameter: $param"); + Koha::Exception->throw("item_barcode_transform called with parameter: $param"); } 1; diff --git a/tools/batchMod.pl b/tools/batchMod.pl index 81745c3e6f..ef6dec19b8 100755 --- a/tools/batchMod.pl +++ b/tools/batchMod.pl @@ -32,7 +32,7 @@ use Encode qw( encode_utf8 ); use Koha::Database; use Koha::DateUtils qw( dt_from_string ); -use Koha::Exceptions::Exception; +use Koha::Exception; use Koha::Biblios; use Koha::Items; use Koha::Patrons; -- 2.39.5