Bugzilla – Attachment 130156 Details for
Bug 29857
We must stringify our exceptions correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29857: (CONCEPT) Switch to singular, add a load method
Bug-29857-CONCEPT-Switch-to-singular-add-a-load-me.patch (text/plain), 4.28 KB, created by
Marcel de Rooy
on 2022-02-04 10:32:55 UTC
(
hide
)
Description:
Bug 29857: (CONCEPT) Switch to singular, add a load method
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-02-04 10:32:55 UTC
Size:
4.28 KB
patch
obsolete
>From 674fd9970f2ac87b31ff2b9b8f6dc66ae607a344 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 4 Feb 2022 10:28:49 +0000 >Subject: [PATCH] Bug 29857: (CONCEPT) Switch to singular, add a load method >Content-Type: text/plain; charset=utf-8 > >The load method calls the Class::Exception import. Allowing you >to skip a use Class::Exception everywhere, and define 'nicer' >exception lists? >--- > Koha/Exception.pm | 14 ++++--- > Koha/Exception/Generic.pm | 82 +++++++++++++++++++++++++++++++++++++++ > 2 files changed, 91 insertions(+), 5 deletions(-) > create mode 100644 Koha/Exception/Generic.pm > >diff --git a/Koha/Exception.pm b/Koha/Exception.pm >index c420777cd2..826f55cacc 100644 >--- a/Koha/Exception.pm >+++ b/Koha/Exception.pm >@@ -18,12 +18,16 @@ package Koha::Exception; > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >+use Exception::Class qw(); > >-use Exception::Class ( >- 'Koha::Exception' => { >- description => "Something went wrong!" >- }, >-); >+INIT { __PACKAGE__->load; } >+ >+sub load { >+ my ( $class, @exceptions ) = @_; >+ push @exceptions, 'Koha::Exception' => { description => "Something went wrong!" } >+ unless @exceptions; >+ Exception::Class->import(@exceptions); >+} > > sub full_message { > my $self = shift; >diff --git a/Koha/Exception/Generic.pm b/Koha/Exception/Generic.pm >new file mode 100644 >index 0000000000..d106027ea9 >--- /dev/null >+++ b/Koha/Exception/Generic.pm >@@ -0,0 +1,82 @@ >+package Koha::Exception::Generic; >+ >+use Modern::Perl; >+use parent qw(Koha::Exception); >+ >+my @exceptions; >+INIT { __PACKAGE__->load( @exceptions ); } >+ >+@exceptions = ( >+ 'Koha::Exception::BadParameter' => { >+ isa => 'Koha::Exception', >+ description => 'A bad parameter was given', >+ fields => ['parameter'], >+ }, >+ 'Koha::Exception::DuplicateObject' => { >+ isa => 'Koha::Exception', >+ description => 'Same object already exists', >+ }, >+ 'Koha::Exception::ObjectNotFound' => { >+ isa => 'Koha::Exception', >+ description => 'The required object doesn\'t exist', >+ }, >+ 'Koha::Exception::ObjectNotCreated' => { >+ isa => 'Koha::Exception', >+ description => 'The object have not been created', >+ }, >+ 'Koha::Exception::CannotDeleteDefault' => { >+ isa => 'Koha::Exception', >+ description => 'The default value cannot be deleted' >+ }, >+ 'Koha::Exception::MissingParameter' => { >+ isa => 'Koha::Exception', >+ description => 'A required parameter is missing' >+ }, >+ 'Koha::Exception::ParameterTooHigh' => { >+ isa => 'Koha::Exception', >+ description => 'A passed parameter value is too high' >+ }, >+ 'Koha::Exception::NoChanges' => { >+ isa => 'Koha::Exception', >+ description => 'No changes were made', >+ }, >+ 'Koha::Exception::WrongParameter' => { >+ isa => 'Koha::Exception', >+ description => 'One or more parameters are wrong', >+ }, >+ 'Koha::Exception::NoPermission' => { >+ isa => 'Koha::Exception', >+ description => 'You do not have permission for this action', >+ }, >+ 'Koha::Exception::CannotAddLibraryLimit' => { >+ isa => 'Koha::Exception', >+ description => 'General problem adding a library limit' >+ }, >+ 'Koha::Exception::UnderMaintenance' => { >+ isa => 'Koha::Exception', >+ description => 'Koha is under maintenance.' >+ }, >+ # Virtualshelves exceptions >+ 'Koha::Exception::Virtualshelves::DuplicateObject' => { >+ isa => 'Koha::Exception::DuplicateObject', >+ description => "Duplicate shelf object", >+ }, >+ 'Koha::Exception::Virtualshelves::InvalidInviteKey' => { >+ isa => 'Koha::Exception', >+ description => 'Invalid key on accepting the share', >+ }, >+ 'Koha::Exception::Virtualshelves::InvalidKeyOnSharing' => { >+ isa => 'Koha::Exception', >+ description=> 'Invalid key on sharing a shelf', >+ }, >+ 'Koha::Exception::Virtualshelves::ShareHasExpired' => { >+ isa => 'Koha::Exception', >+ description=> 'Cannot share this shelf, the share has expired', >+ }, >+ 'Koha::Exception::Virtualshelves::UseDbAdminAccount' => { >+ isa => 'Koha::Exception', >+ description => "Invalid use of database administrator account", >+ } >+); >+ >+1; >-- >2.20.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 29857
:
129329
|
129330
|
130007
|
130008
|
130009
|
130010
|
130011
|
130012
|
130013
|
130014
|
130015
|
130156
|
130157
|
130158
|
130355
|
131112
|
131113
|
131114
|
131115
|
131116
|
131117
|
131232
|
131240
|
131241
|
131242
|
131243
|
131244
|
131256
|
131258
|
131287
|
131288
|
131289
|
131290
|
131291