Bugzilla – Attachment 84830 Details for
Bug 17712
Move availability calculation to the Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17712: Add new Koha::Exceptions
Bug-17712-Add-new-KohaExceptions.patch (text/plain), 15.06 KB, created by
Josef Moravec
on 2019-02-06 21:29:06 UTC
(
hide
)
Description:
Bug 17712: Add new Koha::Exceptions
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2019-02-06 21:29:06 UTC
Size:
15.06 KB
patch
obsolete
>From 998edb4ea4fb3c63b5703e13155917c5535fde78 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Tue, 15 Nov 2016 12:49:30 +0200 >Subject: [PATCH] Bug 17712: Add new Koha::Exceptions > >To describe problems or notes to availability, we will be using Koha::Exceptions. >This patch adds many useful Koha::Exceptions that we can use for this purpose. > >Signed-off-by: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no> >--- > Koha/Exceptions.pm | 27 ++++++++++++++- > Koha/Exceptions/Biblio.pm | 32 +++++++++++++++++ > Koha/Exceptions/Checkout.pm | 66 +++++++++++++++++++++++++++++++++++ > Koha/Exceptions/Hold.pm | 34 ++++++++++++++++++ > Koha/Exceptions/Item.pm | 84 +++++++++++++++++++++++++++++++++++++++++++++ > Koha/Exceptions/ItemType.pm | 18 ++++++++++ > Koha/Exceptions/Patron.pm | 54 +++++++++++++++++++++++++++++ > 7 files changed, 314 insertions(+), 1 deletion(-) > create mode 100644 Koha/Exceptions/Biblio.pm > create mode 100644 Koha/Exceptions/Checkout.pm > create mode 100644 Koha/Exceptions/Item.pm > create mode 100644 Koha/Exceptions/ItemType.pm > >diff --git a/Koha/Exceptions.pm b/Koha/Exceptions.pm >index 72a56cc..8744cae 100644 >--- a/Koha/Exceptions.pm >+++ b/Koha/Exceptions.pm >@@ -10,6 +10,11 @@ use Exception::Class ( > description => 'A bad parameter was given', > fields => ['parameter'], > }, >+ 'Koha::Exceptions::BadParameter' => { >+ isa => 'Koha::Exceptions::Exception', >+ description => 'A bad parameter was given', >+ fields => ['parameter'], >+ }, > 'Koha::Exceptions::DuplicateObject' => { > isa => 'Koha::Exceptions::Exception', > description => 'Same object already exists', >@@ -22,9 +27,29 @@ use Exception::Class ( > isa => 'Koha::Exceptions::Exception', > description => 'The default value cannot be deleted' > }, >+ 'Koha::Exceptions::InvalidDate' => { >+ isa => 'Koha::Exceptions::Exception', >+ description => "Date is invalid.", >+ fields => ["date"], >+ }, > 'Koha::Exceptions::MissingParameter' => { > isa => 'Koha::Exceptions::Exception', >- description => 'A required parameter is missing' >+ description => 'A required parameter is missing', >+ fields => ["parameter"], >+ }, >+ 'Koha::Exceptions::AuthenticationRequired' => { >+ isa => 'Koha::Exceptions::Exception', >+ description => 'Authentication is required.', >+ }, >+ 'Koha::Exceptions::NoPermission' => { >+ isa => 'Koha::Exceptions::Exception', >+ description => 'No permission to access this resource.', >+ fields => ["required_permissions"] >+ }, >+ 'Koha::Exceptions::NotImplemented' => { >+ isa => 'Koha::Exceptions::Exception', >+ description => 'A subroutine is not implemented', >+ fields => ["subroutine"] > }, > 'Koha::Exceptions::NoChanges' => { > isa => 'Koha::Exceptions::Exception', >diff --git a/Koha/Exceptions/Biblio.pm b/Koha/Exceptions/Biblio.pm >new file mode 100644 >index 0000000..21ea965 >--- /dev/null >+++ b/Koha/Exceptions/Biblio.pm >@@ -0,0 +1,32 @@ >+package Koha::Exceptions::Biblio; >+ >+use Modern::Perl; >+ >+use Exception::Class ( >+ >+ 'Koha::Exceptions::Biblio' => { >+ description => 'Something went wrong!', >+ }, >+ 'Koha::Exceptions::Biblio::AnotherItemCheckedOut' => { >+ isa => 'Koha::Exceptions::Biblio', >+ description => "Another item from same biblio already checked out.", >+ fields => ["itemnumbers"], >+ }, >+ 'Koha::Exceptions::Biblio::CheckedOut' => { >+ isa => 'Koha::Exceptions::Biblio', >+ description => "Biblio is already checked out for patron.", >+ fields => ['biblionumber'], >+ }, >+ 'Koha::Exceptions::Biblio::NoAvailableItems' => { >+ isa => 'Koha::Exceptions::Biblio', >+ description => "Biblio does not have any available items.", >+ }, >+ 'Koha::Exceptions::Biblio::NotFound' => { >+ isa => 'Koha::Exceptions::Biblio', >+ description => "Biblio not found.", >+ fields => ['biblionumber'], >+ }, >+ >+); >+ >+1; >diff --git a/Koha/Exceptions/Checkout.pm b/Koha/Exceptions/Checkout.pm >new file mode 100644 >index 0000000..611c338 >--- /dev/null >+++ b/Koha/Exceptions/Checkout.pm >@@ -0,0 +1,66 @@ >+package Koha::Exceptions::Checkout; >+ >+use Modern::Perl; >+ >+use Exception::Class ( >+ >+ 'Koha::Exceptions::Checkout' => { >+ description => 'Something went wrong!', >+ }, >+ 'Koha::Exceptions::Checkout::DueDateBeforeNow' => { >+ isa => 'Koha::Exceptions::Checkout', >+ description => 'Given due date is already in the past.', >+ fields => ["duedate", "now"], >+ }, >+ 'Koha::Exceptions::Checkout::Fee' => { >+ isa => 'Koha::Exceptions::Checkout', >+ description => "There are checkout fees.", >+ fields => ["amount"], >+ }, >+ 'Koha::Exceptions::Checkout::InvalidDueDate' => { >+ isa => 'Koha::Exceptions::Checkout', >+ description => 'Given due date is invalid.', >+ fields => ["duedate"], >+ }, >+ 'Koha::Exceptions::Checkout::MaximumCheckoutsReached' => { >+ isa => 'Koha::Exceptions::Checkout', >+ description => "Maximum number of checkouts have been reached, or none allowed.", >+ fields => ["max_checkouts_allowed", "current_checkout_count"], >+ }, >+ 'Koha::Exceptions::Checkout::MaximumOnsiteCheckoutsReached' => { >+ isa => 'Koha::Exceptions::Checkout', >+ description => "Maximum number of on-site checkouts have been reached.", >+ fields => ["max_onsite_checkouts", "current_onsite_checkouts"], >+ }, >+ 'Koha::Exceptions::Checkout::NoMoreRenewals' => { >+ isa => 'Koha::Exceptions::Checkout', >+ description => "No more renewals are allowed.", >+ }, >+ 'Koha::Exceptions::Checkout::NoRenewalForOnsiteCheckouts' => { >+ isa => 'Koha::Exceptions::Checkout', >+ description => "On-site checkouts cannot be renewed.", >+ }, >+ 'Koha::Exceptions::Checkout::OnsiteCheckoutsDisabled' => { >+ isa => 'Koha::Exceptions::Checkout', >+ description => "On-site checkouts are disabled.", >+ }, >+ 'Koha::Exceptions::Checkout::OnsiteCheckoutWillBeSwitched' => { >+ isa => 'Koha::Exceptions::Checkout', >+ description => "On-site checkout will be switched to normal checkout.", >+ }, >+ 'Koha::Exceptions::Checkout::PreviouslyCheckedOut' => { >+ isa => 'Koha::Exceptions::Checkout', >+ description => "This biblio has been previously checked out by this patron.", >+ }, >+ 'Koha::Exceptions::Checkout::Renew' => { >+ isa => 'Koha::Exceptions::Checkout', >+ description => "Checkout will be renewed.", >+ }, >+ 'Koha::Exceptions::Checkout::ZeroCheckoutsAllowed' => { >+ isa => 'Koha::Exceptions::Checkout', >+ description => "Matching issuing rule that does not allow any checkouts.", >+ }, >+ >+); >+ >+1; >diff --git a/Koha/Exceptions/Hold.pm b/Koha/Exceptions/Hold.pm >index 5e6eeb0..e339581 100644 >--- a/Koha/Exceptions/Hold.pm >+++ b/Koha/Exceptions/Hold.pm >@@ -27,6 +27,40 @@ use Exception::Class ( > isa => 'Koha::Exceptions::Hold', > description => "Found holds cannot be suspended", > fields => ['status'] >+ }, >+ 'Koha::Exceptions::Hold::ItemLevelHoldNotAllowed' => { >+ isa => 'Koha::Exceptions::Hold', >+ description => "Item level hold is not allowed.", >+ }, >+ 'Koha::Exceptions::Hold::MaximumHoldsReached' => { >+ isa => 'Koha::Exceptions::Hold', >+ description => "Maximum number of holds have been reached.", >+ fields => ["max_holds_allowed", "current_hold_count"], >+ }, >+ 'Koha::Exceptions::Hold::MaximumHoldsForRecordReached' => { >+ isa => 'Koha::Exceptions::Hold', >+ description => "Maximum number of holds for a record have been reached.", >+ fields => ["max_holds_allowed", "current_hold_count"], >+ }, >+ 'Koha::Exceptions::Hold::NotAllowedByLibrary' => { >+ isa => 'Koha::Exceptions::Hold', >+ description => "This library does not allow holds.", >+ }, >+ 'Koha::Exceptions::Hold::NotAllowedFromOtherLibraries' => { >+ isa => 'Koha::Exceptions::Hold', >+ description => "Cannot hold from other libraries.", >+ }, >+ 'Koha::Exceptions::Hold::NotAllowedInOPAC' => { >+ isa => 'Koha::Exceptions::Hold', >+ description => "Holds are disabled in OPAC.", >+ }, >+ 'Koha::Exceptions::Hold::OnShelfNotAllowed' => { >+ isa => 'Koha::Exceptions::Hold', >+ description => "On-shelf holds are not allowed.", >+ }, >+ 'Koha::Exceptions::Hold::ZeroHoldsAllowed' => { >+ isa => 'Koha::Exceptions::Hold', >+ description => "Matching hold rule that does not allow any holds.", > } > ); > >diff --git a/Koha/Exceptions/Item.pm b/Koha/Exceptions/Item.pm >new file mode 100644 >index 0000000..ee2f7ab >--- /dev/null >+++ b/Koha/Exceptions/Item.pm >@@ -0,0 +1,84 @@ >+package Koha::Exceptions::Item; >+ >+use Modern::Perl; >+ >+use Exception::Class ( >+ >+ 'Koha::Exceptions::Item' => { >+ description => 'Something went wrong!', >+ }, >+ 'Koha::Exceptions::Item::AlreadyHeldForThisPatron' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "Item already held for this patron.", >+ }, >+ 'Koha::Exceptions::Item::CannotBeTransferred' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "Item cannot be transferred from holding library to given library.", >+ fields => ["from_library", "to_library"], >+ }, >+ 'Koha::Exceptions::Item::CheckedOut' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "Item has already been checked out.", >+ fields => ["borrowernumber", "date_due"], >+ }, >+ 'Koha::Exceptions::Item::Damaged' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "Item is marked as damaged.", >+ }, >+ 'Koha::Exceptions::Item::FromAnotherLibrary' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "Libraries are independent and item is not from this library.", >+ fields => ["current_library", "from_library"], >+ }, >+ 'Koha::Exceptions::Item::Held' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "Item held.", >+ fields => ["borrowernumber", "hold_queue_length", "status"], >+ }, >+ 'Koha::Exceptions::Item::HighHolds' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "High demand item. Loan period shortened.", >+ fields => ["num_holds", "duration", "returndate"], >+ }, >+ 'Koha::Exceptions::Item::Lost' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "Item is marked as lost.", >+ fields => ["code", "status"], >+ }, >+ 'Koha::Exceptions::Item::NotForLoan' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "Item is marked as not for loan.", >+ fields => ["code", "status"], >+ }, >+ 'Koha::Exceptions::Item::NotFound' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "Item not found.", >+ fields => ['itemnumber'], >+ }, >+ 'Koha::Exceptions::Item::NotForLoanForcing' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "Item is marked as not for loan, but it is possible to override.", >+ fields => ["notforloan"], >+ }, >+ 'Koha::Exceptions::Item::Restricted' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "Item is marked as restricted.", >+ }, >+ 'Koha::Exceptions::Item::Transfer' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "Item is being transferred.", >+ fields => ["datesent", "from_library", "to_library"], >+ }, >+ 'Koha::Exceptions::Item::UnknownBarcode' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "Item has unknown barcode, or no barcode at all.", >+ fields => ["barcode"], >+ }, >+ 'Koha::Exceptions::Item::Withdrawn' => { >+ isa => 'Koha::Exceptions::Item', >+ description => "Item is marked as withdrawn.", >+ } >+ >+); >+ >+1; >diff --git a/Koha/Exceptions/ItemType.pm b/Koha/Exceptions/ItemType.pm >new file mode 100644 >index 0000000..4ceb4b3 >--- /dev/null >+++ b/Koha/Exceptions/ItemType.pm >@@ -0,0 +1,18 @@ >+package Koha::Exceptions::ItemType; >+ >+use Modern::Perl; >+ >+use Exception::Class ( >+ >+ 'Koha::Exceptions::ItemType' => { >+ description => 'Something went wrong!', >+ }, >+ 'Koha::Exceptions::ItemType::NotForLoan' => { >+ isa => 'Koha::Exceptions::ItemType', >+ description => "This type of items are not for loan.", >+ fields => ["itemtype", "status", "code"], >+ }, >+ >+); >+ >+1; >diff --git a/Koha/Exceptions/Patron.pm b/Koha/Exceptions/Patron.pm >index 8eac9c9..e3af12d 100644 >--- a/Koha/Exceptions/Patron.pm >+++ b/Koha/Exceptions/Patron.pm >@@ -3,12 +3,66 @@ package Koha::Exceptions::Patron; > use Modern::Perl; > > use Exception::Class ( >+ > 'Koha::Exceptions::Patron' => { > description => "Something went wrong!" > }, > 'Koha::Exceptions::Patron::FailedDelete' => { > description => "Deleting patron failed" > }, >+ 'Koha::Exceptions::Patron::AgeRestricted' => { >+ isa => 'Koha::Exceptions::Patron', >+ description => "Age restriction applies for patron.", >+ fields => ["age_restriction"], >+ }, >+ 'Koha::Exceptions::Patron::CardExpired' => { >+ isa => 'Koha::Exceptions::Patron', >+ description => "Patron's card has expired.", >+ fields => ["expiration_date"], >+ }, >+ 'Koha::Exceptions::Patron::CardLost' => { >+ isa => 'Koha::Exceptions::Patron', >+ description => "Patron's card has been marked as lost.", >+ }, >+ 'Koha::Exceptions::Patron::Debarred' => { >+ isa => 'Koha::Exceptions::Patron', >+ description => "Patron is debarred.", >+ fields => ["expiration", "comment"], >+ }, >+ 'Koha::Exceptions::Patron::DebarredOverdue' => { >+ isa => 'Koha::Exceptions::Patron', >+ description => "Patron is debarred because of overdue checkouts.", >+ fields => ["number_of_overdues"], >+ }, >+ 'Koha::Exceptions::Patron::Debt' => { >+ isa => 'Koha::Exceptions::Patron', >+ description => "Patron has debts.", >+ fields => ["max_outstanding", "current_outstanding"], >+ }, >+ 'Koha::Exceptions::Patron::DebtGuarantees' => { >+ isa => 'Koha::Exceptions::Patron', >+ description => "Patron's guarantees have debts.", >+ fields => ["max_outstanding", "current_outstanding", "guarantees"], >+ }, >+ 'Koha::Exceptions::Patron::FromAnotherLibrary' => { >+ isa => 'Koha::Exceptions::Patron', >+ description => "Libraries are independent and this patron is from another library than we are now logged in.", >+ fields => ["patron_branch", "current_branch"], >+ }, >+ 'Koha::Exceptions::Patron::GoneNoAddress' => { >+ isa => 'Koha::Exceptions::Patron', >+ description => "Patron gone no address.", >+ }, >+ 'Koha::Exceptions::Patron::NotFound' => { >+ isa => 'Koha::Exceptions::Patron', >+ description => "Patron not found.", >+ fields => ['borrowernumber'], >+ }, >+ 'Koha::Exceptions::Patron::OtherCharges' => { >+ isa => 'Koha::Exceptions::Patron', >+ description => "Patron has other outstanding charges.", >+ fields => ["balance", "other_charges"], >+ } > ); > > 1; >-- >2.1.4
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 17712
:
57921
|
57923
|
58446
|
58447
|
58449
|
58450
|
58451
|
58452
|
58453
|
58454
|
60147
|
60148
|
60149
|
60150
|
60151
|
60152
|
60153
|
60154
|
60261
|
60262
|
60263
|
60264
|
60265
|
62719
|
62720
|
62721
|
62722
|
62723
|
62724
|
62725
|
62726
|
63343
|
63344
|
63345
|
63346
|
63347
|
63348
|
63349
|
63350
| 84830 |
84831
|
84832
|
84833
|
84834
|
84835
|
84836
|
84837
|
84838
|
84839