From ea337fe0ae8cc6e896082cb4da1124d4baf19a4c Mon Sep 17 00:00:00 2001 From: Olli-Antti Kivilahti Date: Thu, 9 Mar 2017 16:40:47 +0200 Subject: [PATCH] Bug 13995 - Proper Exception handling --- Koha/Exception.pm | 33 ++++++++++++++++++++++ Koha/Exception/BadAuthenticationToken.pm | 29 +++++++++++++++++++ Koha/Exception/BadEncoding.pm | 29 +++++++++++++++++++ Koha/Exception/BadParameter.pm | 29 +++++++++++++++++++ Koha/Exception/BadSystemPreference.pm | 30 ++++++++++++++++++++ Koha/Exception/BatchOverlay.pm | 30 ++++++++++++++++++++ Koha/Exception/BatchOverlay/DuplicateSearchTerm.pm | 29 +++++++++++++++++++ Koha/Exception/BatchOverlay/LocalSearch.pm | 29 +++++++++++++++++++ .../Exception/BatchOverlay/LocalSearchAmbiguous.pm | 29 +++++++++++++++++++ .../Exception/BatchOverlay/LocalSearchNoResults.pm | 29 +++++++++++++++++++ Koha/Exception/BatchOverlay/Marc.pm | 29 +++++++++++++++++++ Koha/Exception/BatchOverlay/NoBreedinRecord.pm | 29 +++++++++++++++++++ .../BatchOverlay/RemoteSearchAmbiguous.pm | 29 +++++++++++++++++++ Koha/Exception/BatchOverlay/RemoteSearchFailed.pm | 29 +++++++++++++++++++ .../BatchOverlay/RemoteSearchNoResults.pm | 29 +++++++++++++++++++ Koha/Exception/BatchOverlay/UnknownMatcher.pm | 29 +++++++++++++++++++ Koha/Exception/BatchOverlay/UnknownRemoteTarget.pm | 29 +++++++++++++++++++ .../BatchOverlay/UnknownSearchAlgorithm.pm | 29 +++++++++++++++++++ Koha/Exception/ConnectionFailed.pm | 29 +++++++++++++++++++ Koha/Exception/DB.pm | 29 +++++++++++++++++++ Koha/Exception/Deduplicator.pm | 29 +++++++++++++++++++ Koha/Exception/Deduplicator/TooManyMatches.pm | 29 +++++++++++++++++++ Koha/Exception/DuplicateObject.pm | 29 +++++++++++++++++++ Koha/Exception/Expired.pm | 29 +++++++++++++++++++ Koha/Exception/FeatureUnavailable.pm | 29 +++++++++++++++++++ Koha/Exception/File.pm | 29 +++++++++++++++++++ Koha/Exception/Labels.pm | 29 +++++++++++++++++++ Koha/Exception/Labels/UnknownItems.pm | 30 ++++++++++++++++++++ Koha/Exception/LoginFailed.pm | 29 +++++++++++++++++++ Koha/Exception/Logout.pm | 29 +++++++++++++++++++ Koha/Exception/NoPermission.pm | 29 +++++++++++++++++++ Koha/Exception/NoSystemPreference.pm | 30 ++++++++++++++++++++ Koha/Exception/NotImplemented.pm | 29 +++++++++++++++++++ Koha/Exception/ObjectExists.pm | 29 +++++++++++++++++++ Koha/Exception/Parse.pm | 29 +++++++++++++++++++ Koha/Exception/RemoteInvocation.pm | 29 +++++++++++++++++++ Koha/Exception/SMSDeliveryFailure.pm | 29 +++++++++++++++++++ Koha/Exception/Search.pm | 29 +++++++++++++++++++ Koha/Exception/SelfService.pm | 29 +++++++++++++++++++ .../SelfService/BlockedBorrowerCategory.pm | 17 +++++++++++ Koha/Exception/SelfService/OpeningHours.pm | 18 ++++++++++++ Koha/Exception/SelfService/PermissionRevoked.pm | 17 +++++++++++ Koha/Exception/SelfService/TACNotAccepted.pm | 17 +++++++++++ Koha/Exception/SelfService/Underage.pm | 18 ++++++++++++ Koha/Exception/ServiceTemporarilyUnavailable.pm | 29 +++++++++++++++++++ Koha/Exception/SubroutineCall.pm | 17 +++++++++++ Koha/Exception/SystemCall.pm | 29 +++++++++++++++++++ Koha/Exception/UnknownObject.pm | 29 +++++++++++++++++++ Koha/Exception/UnknownProgramState.pm | 29 +++++++++++++++++++ Koha/Exception/UnknownProtocol.pm | 29 +++++++++++++++++++ Koha/Exception/VersionMismatch.pm | 29 +++++++++++++++++++ t/Exception.t | 25 ++++++++++++++++ 52 files changed, 1442 insertions(+) create mode 100644 Koha/Exception.pm create mode 100644 Koha/Exception/BadAuthenticationToken.pm create mode 100644 Koha/Exception/BadEncoding.pm create mode 100644 Koha/Exception/BadParameter.pm create mode 100644 Koha/Exception/BadSystemPreference.pm create mode 100644 Koha/Exception/BatchOverlay.pm create mode 100644 Koha/Exception/BatchOverlay/DuplicateSearchTerm.pm create mode 100644 Koha/Exception/BatchOverlay/LocalSearch.pm create mode 100644 Koha/Exception/BatchOverlay/LocalSearchAmbiguous.pm create mode 100644 Koha/Exception/BatchOverlay/LocalSearchNoResults.pm create mode 100644 Koha/Exception/BatchOverlay/Marc.pm create mode 100644 Koha/Exception/BatchOverlay/NoBreedinRecord.pm create mode 100644 Koha/Exception/BatchOverlay/RemoteSearchAmbiguous.pm create mode 100644 Koha/Exception/BatchOverlay/RemoteSearchFailed.pm create mode 100644 Koha/Exception/BatchOverlay/RemoteSearchNoResults.pm create mode 100644 Koha/Exception/BatchOverlay/UnknownMatcher.pm create mode 100644 Koha/Exception/BatchOverlay/UnknownRemoteTarget.pm create mode 100644 Koha/Exception/BatchOverlay/UnknownSearchAlgorithm.pm create mode 100644 Koha/Exception/ConnectionFailed.pm create mode 100644 Koha/Exception/DB.pm create mode 100644 Koha/Exception/Deduplicator.pm create mode 100644 Koha/Exception/Deduplicator/TooManyMatches.pm create mode 100644 Koha/Exception/DuplicateObject.pm create mode 100644 Koha/Exception/Expired.pm create mode 100644 Koha/Exception/FeatureUnavailable.pm create mode 100644 Koha/Exception/File.pm create mode 100644 Koha/Exception/Labels.pm create mode 100644 Koha/Exception/Labels/UnknownItems.pm create mode 100644 Koha/Exception/LoginFailed.pm create mode 100644 Koha/Exception/Logout.pm create mode 100644 Koha/Exception/NoPermission.pm create mode 100644 Koha/Exception/NoSystemPreference.pm create mode 100644 Koha/Exception/NotImplemented.pm create mode 100644 Koha/Exception/ObjectExists.pm create mode 100644 Koha/Exception/Parse.pm create mode 100644 Koha/Exception/RemoteInvocation.pm create mode 100644 Koha/Exception/SMSDeliveryFailure.pm create mode 100644 Koha/Exception/Search.pm create mode 100644 Koha/Exception/SelfService.pm create mode 100644 Koha/Exception/SelfService/BlockedBorrowerCategory.pm create mode 100644 Koha/Exception/SelfService/OpeningHours.pm create mode 100644 Koha/Exception/SelfService/PermissionRevoked.pm create mode 100644 Koha/Exception/SelfService/TACNotAccepted.pm create mode 100644 Koha/Exception/SelfService/Underage.pm create mode 100644 Koha/Exception/ServiceTemporarilyUnavailable.pm create mode 100644 Koha/Exception/SubroutineCall.pm create mode 100644 Koha/Exception/SystemCall.pm create mode 100644 Koha/Exception/UnknownObject.pm create mode 100644 Koha/Exception/UnknownProgramState.pm create mode 100644 Koha/Exception/UnknownProtocol.pm create mode 100644 Koha/Exception/VersionMismatch.pm create mode 100644 t/Exception.t diff --git a/Koha/Exception.pm b/Koha/Exception.pm new file mode 100644 index 0000000..84c26b3 --- /dev/null +++ b/Koha/Exception.pm @@ -0,0 +1,33 @@ +package Koha::Exception; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception' => { + description => 'Koha exceptions base class', + }, +); + +sub newFromDie { + my ($class, $die) = @_; + return Koha::Exception->new(error => "$die"); +} + +return 1; diff --git a/Koha/Exception/BadAuthenticationToken.pm b/Koha/Exception/BadAuthenticationToken.pm new file mode 100644 index 0000000..49bc816 --- /dev/null +++ b/Koha/Exception/BadAuthenticationToken.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BadAuthenticationToken; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BadAuthenticationToken' => { + isa => 'Koha::Exception', + description => 'Authentication token is invalid', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/BadEncoding.pm b/Koha/Exception/BadEncoding.pm new file mode 100644 index 0000000..88eb263 --- /dev/null +++ b/Koha/Exception/BadEncoding.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BadEncoding; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BadEncoding' => { + isa => 'Koha::Exception', + description => 'Something wrong with the character encoding', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/BadParameter.pm b/Koha/Exception/BadParameter.pm new file mode 100644 index 0000000..0b64e14 --- /dev/null +++ b/Koha/Exception/BadParameter.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BadParameter; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BadParameter' => { + isa => 'Koha::Exception', + description => 'Something wrong with the given parameters', + }, +); + +return 1; diff --git a/Koha/Exception/BadSystemPreference.pm b/Koha/Exception/BadSystemPreference.pm new file mode 100644 index 0000000..5738eec --- /dev/null +++ b/Koha/Exception/BadSystemPreference.pm @@ -0,0 +1,30 @@ +package Koha::Exception::BadSystemPreference; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BadSystemPreference' => { + isa => 'Koha::Exception', + description => 'System preference value is incomprehensible', + fields => ['syspref'], + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/BatchOverlay.pm b/Koha/Exception/BatchOverlay.pm new file mode 100644 index 0000000..1259efe --- /dev/null +++ b/Koha/Exception/BatchOverlay.pm @@ -0,0 +1,30 @@ +package Koha::Exception::BatchOverlay; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BatchOverlay' => { + isa => 'Koha::Exception', + description => "Extendable core class for BatchOverlay Exceptions.", + fields => [ 'records', 'overlayRule', 'searchAlgorithm', 'searchTerm' ], + }, +); + +return 1; diff --git a/Koha/Exception/BatchOverlay/DuplicateSearchTerm.pm b/Koha/Exception/BatchOverlay/DuplicateSearchTerm.pm new file mode 100644 index 0000000..33233a3 --- /dev/null +++ b/Koha/Exception/BatchOverlay/DuplicateSearchTerm.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BatchOverlay::DuplicateSearchTerm; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BatchOverlay::DuplicateSearchTerm' => { + isa => 'Koha::Exception::BatchOverlay', + description => "Same search is requested twice. This can cause a myriad of problems with the search and indexing subsystem.", + }, +); + +return 1; diff --git a/Koha/Exception/BatchOverlay/LocalSearch.pm b/Koha/Exception/BatchOverlay/LocalSearch.pm new file mode 100644 index 0000000..0937d17 --- /dev/null +++ b/Koha/Exception/BatchOverlay/LocalSearch.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BatchOverlay::LocalSearch; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BatchOverlay::LocalSearch' => { + isa => 'Koha::Exception::BatchOverlay', + description => 'Something happened when looking for the right local record using a search term.', + }, +); + +return 1; diff --git a/Koha/Exception/BatchOverlay/LocalSearchAmbiguous.pm b/Koha/Exception/BatchOverlay/LocalSearchAmbiguous.pm new file mode 100644 index 0000000..e74a539 --- /dev/null +++ b/Koha/Exception/BatchOverlay/LocalSearchAmbiguous.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BatchOverlay::LocalSearchAmbiguous; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BatchOverlay::LocalSearchAmbiguous' => { + isa => 'Koha::Exception::BatchOverlay', + description => "Local search term doesn't return a unique result.", + }, +); + +return 1; diff --git a/Koha/Exception/BatchOverlay/LocalSearchNoResults.pm b/Koha/Exception/BatchOverlay/LocalSearchNoResults.pm new file mode 100644 index 0000000..e9c7d32 --- /dev/null +++ b/Koha/Exception/BatchOverlay/LocalSearchNoResults.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BatchOverlay::LocalSearchNoResults; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BatchOverlay::LocalSearchNoResults' => { + isa => 'Koha::Exception::BatchOverlay', + description => 'No local biblio matches the given search result.', + }, +); + +return 1; diff --git a/Koha/Exception/BatchOverlay/Marc.pm b/Koha/Exception/BatchOverlay/Marc.pm new file mode 100644 index 0000000..abd3aba --- /dev/null +++ b/Koha/Exception/BatchOverlay/Marc.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BatchOverlay::Marc; + +# Copyright 2016 Koha-Suomi Oy +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BatchOverlay::Marc' => { + isa => 'Koha::Exception::BatchOverlay', + description => 'Something wrong with the MARC record', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/BatchOverlay/NoBreedinRecord.pm b/Koha/Exception/BatchOverlay/NoBreedinRecord.pm new file mode 100644 index 0000000..d607a6f --- /dev/null +++ b/Koha/Exception/BatchOverlay/NoBreedinRecord.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BatchOverlay::NoBreedinRecord; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BatchOverlay::NoBreedinRecord' => { + isa => 'Koha::Exception::BatchOverlay', + description => 'A record which should be in the breeding-tables is not there?', + }, +); + +return 1; diff --git a/Koha/Exception/BatchOverlay/RemoteSearchAmbiguous.pm b/Koha/Exception/BatchOverlay/RemoteSearchAmbiguous.pm new file mode 100644 index 0000000..f3e6ece --- /dev/null +++ b/Koha/Exception/BatchOverlay/RemoteSearchAmbiguous.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BatchOverlay::RemoteSearchNoResults; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BatchOverlay::RemoteSearchNoResults' => { + isa => 'Koha::Exception::BatchOverlay', + description => 'Searching from the remote target returned no results.', + }, +); + +return 1; diff --git a/Koha/Exception/BatchOverlay/RemoteSearchFailed.pm b/Koha/Exception/BatchOverlay/RemoteSearchFailed.pm new file mode 100644 index 0000000..69c447d --- /dev/null +++ b/Koha/Exception/BatchOverlay/RemoteSearchFailed.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BatchOverlay::RemoteSearchAmbiguous; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BatchOverlay::RemoteSearchAmbiguous' => { + isa => 'Koha::Exception::BatchOverlay', + description => 'Searching from the remote target returned more results than expected.', + }, +); + +return 1; diff --git a/Koha/Exception/BatchOverlay/RemoteSearchNoResults.pm b/Koha/Exception/BatchOverlay/RemoteSearchNoResults.pm new file mode 100644 index 0000000..f0d8dc0 --- /dev/null +++ b/Koha/Exception/BatchOverlay/RemoteSearchNoResults.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BatchOverlay::RemoteSearchFailed; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BatchOverlay::RemoteSearchFailed' => { + isa => 'Koha::Exception::BatchOverlay', + description => 'Searching from the remote target failed.', + }, +); + +return 1; diff --git a/Koha/Exception/BatchOverlay/UnknownMatcher.pm b/Koha/Exception/BatchOverlay/UnknownMatcher.pm new file mode 100644 index 0000000..a5b2d91 --- /dev/null +++ b/Koha/Exception/BatchOverlay/UnknownMatcher.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BatchOverlay::UnknownMatcher; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BatchOverlay::UnknownMatcher' => { + isa => 'Koha::Exception::BatchOverlay', + description => "Configured Matcher doesn't exist.", + }, +); + +return 1; diff --git a/Koha/Exception/BatchOverlay/UnknownRemoteTarget.pm b/Koha/Exception/BatchOverlay/UnknownRemoteTarget.pm new file mode 100644 index 0000000..7cdfc12 --- /dev/null +++ b/Koha/Exception/BatchOverlay/UnknownRemoteTarget.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BatchOverlay::UnknownRemoteTarget; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BatchOverlay::UnknownRemoteTarget' => { + isa => 'Koha::Exception::BatchOverlay', + description => "Configured Remote target doesn't exist.", + }, +); + +return 1; diff --git a/Koha/Exception/BatchOverlay/UnknownSearchAlgorithm.pm b/Koha/Exception/BatchOverlay/UnknownSearchAlgorithm.pm new file mode 100644 index 0000000..b82a5f6 --- /dev/null +++ b/Koha/Exception/BatchOverlay/UnknownSearchAlgorithm.pm @@ -0,0 +1,29 @@ +package Koha::Exception::BatchOverlay::UnknownSearchAlgorithm; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::BatchOverlay::UnknownSearchAlgorithm' => { + isa => 'Koha::Exception::BatchOverlay', + description => "Requested search algorithm doesn't exist.", + }, +); + +return 1; diff --git a/Koha/Exception/ConnectionFailed.pm b/Koha/Exception/ConnectionFailed.pm new file mode 100644 index 0000000..09dc8cc --- /dev/null +++ b/Koha/Exception/ConnectionFailed.pm @@ -0,0 +1,29 @@ +package Koha::Exception::ConnectionFailed; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::ConnectionFailed' => { + isa => 'Koha::Exception', + description => 'Connecting to host failed', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/DB.pm b/Koha/Exception/DB.pm new file mode 100644 index 0000000..53cd23e --- /dev/null +++ b/Koha/Exception/DB.pm @@ -0,0 +1,29 @@ +package Koha::Exception::DB; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::DB' => { + isa => 'Koha::Exception', + description => 'Something wrong with the database', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/Deduplicator.pm b/Koha/Exception/Deduplicator.pm new file mode 100644 index 0000000..dbc1a07 --- /dev/null +++ b/Koha/Exception/Deduplicator.pm @@ -0,0 +1,29 @@ +package Koha::Exception::Deduplicator; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::Deduplicator' => { + isa => 'Koha::Exception', + description => "Deduplicator base exception class", + }, +); + +return 1; diff --git a/Koha/Exception/Deduplicator/TooManyMatches.pm b/Koha/Exception/Deduplicator/TooManyMatches.pm new file mode 100644 index 0000000..f141779 --- /dev/null +++ b/Koha/Exception/Deduplicator/TooManyMatches.pm @@ -0,0 +1,29 @@ +package Koha::Exception::Deduplicator::TooManyMatches; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::Deduplicator::TooManyMatches' => { + isa => 'Koha::Exception::Deduplicator', + description => "Deduplicator has found too many matches for one deduplicated record", + }, +); + +return 1; diff --git a/Koha/Exception/DuplicateObject.pm b/Koha/Exception/DuplicateObject.pm new file mode 100644 index 0000000..2e35128 --- /dev/null +++ b/Koha/Exception/DuplicateObject.pm @@ -0,0 +1,29 @@ +package Koha::Exception::DuplicateObject; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::DuplicateObject' => { + isa => 'Koha::Exception', + description => 'Same object already exists', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/Expired.pm b/Koha/Exception/Expired.pm new file mode 100644 index 0000000..f9d9876 --- /dev/null +++ b/Koha/Exception/Expired.pm @@ -0,0 +1,29 @@ +package Koha::Exception::Expired; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::Expired' => { + isa => 'Koha::Exception', + description => 'Object expired and is now stale', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/FeatureUnavailable.pm b/Koha/Exception/FeatureUnavailable.pm new file mode 100644 index 0000000..8187218 --- /dev/null +++ b/Koha/Exception/FeatureUnavailable.pm @@ -0,0 +1,29 @@ +package Koha::Exception::FeatureUnavailable; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::FeatureUnavailable' => { + isa => 'Koha::Exception', + description => 'Feature requested is not currently available', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/File.pm b/Koha/Exception/File.pm new file mode 100644 index 0000000..17ee4d0 --- /dev/null +++ b/Koha/Exception/File.pm @@ -0,0 +1,29 @@ +package Koha::Exception::File; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::File' => { + isa => 'Koha::Exception', + description => 'Something wrong with the given file', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/Labels.pm b/Koha/Exception/Labels.pm new file mode 100644 index 0000000..56ba01b --- /dev/null +++ b/Koha/Exception/Labels.pm @@ -0,0 +1,29 @@ +package Koha::Exception::Labels; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::Labels' => { + isa => 'Koha::Exception', + description => "Labels base exception class", + }, +); + +return 1; diff --git a/Koha/Exception/Labels/UnknownItems.pm b/Koha/Exception/Labels/UnknownItems.pm new file mode 100644 index 0000000..06df8e9 --- /dev/null +++ b/Koha/Exception/Labels/UnknownItems.pm @@ -0,0 +1,30 @@ +package Koha::Exception::Labels::UnknownItems; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::Labels::UnknownItems' => { + isa => 'Koha::Exception::Labels', + description => 'a bunch of Items cannot be found from the given input', + fields => [ 'badBunch' ], + }, +); + +return 1; diff --git a/Koha/Exception/LoginFailed.pm b/Koha/Exception/LoginFailed.pm new file mode 100644 index 0000000..38ff8c1 --- /dev/null +++ b/Koha/Exception/LoginFailed.pm @@ -0,0 +1,29 @@ +package Koha::Exception::LoginFailed; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::LoginFailed' => { + isa => 'Koha::Exception', + description => 'Login to host failed', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/Logout.pm b/Koha/Exception/Logout.pm new file mode 100644 index 0000000..07a3e31 --- /dev/null +++ b/Koha/Exception/Logout.pm @@ -0,0 +1,29 @@ +package Koha::Exception::Logout; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::Logout' => { + isa => 'Koha::Exception', + description => 'User logged out, catch this and redirect.', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/NoPermission.pm b/Koha/Exception/NoPermission.pm new file mode 100644 index 0000000..0a5e8d6 --- /dev/null +++ b/Koha/Exception/NoPermission.pm @@ -0,0 +1,29 @@ +package Koha::Exception::NoPermission; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::NoPermission' => { + isa => 'Koha::Exception', + description => 'User has no permission to do whatever he was up to', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/NoSystemPreference.pm b/Koha/Exception/NoSystemPreference.pm new file mode 100644 index 0000000..6fa2e8b --- /dev/null +++ b/Koha/Exception/NoSystemPreference.pm @@ -0,0 +1,30 @@ +package Koha::Exception::NoSystemPreference; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::NoSystemPreference' => { + isa => 'Koha::Exception', + description => 'Required system preference is not set', + fields => ['syspref'], + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/NotImplemented.pm b/Koha/Exception/NotImplemented.pm new file mode 100644 index 0000000..eea3d4d --- /dev/null +++ b/Koha/Exception/NotImplemented.pm @@ -0,0 +1,29 @@ +package Koha::Exception::NotImplemented; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::NotImplemented' => { + isa => 'Koha::Exception', + description => 'Subroutine requires implementation.', + }, +); + +return 1; diff --git a/Koha/Exception/ObjectExists.pm b/Koha/Exception/ObjectExists.pm new file mode 100644 index 0000000..b9b4883 --- /dev/null +++ b/Koha/Exception/ObjectExists.pm @@ -0,0 +1,29 @@ +package Koha::Exception::ObjectExists; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::ObjectExists' => { + isa => 'Koha::Exception', + description => 'The given Object already exists', + }, +); + +return 1; diff --git a/Koha/Exception/Parse.pm b/Koha/Exception/Parse.pm new file mode 100644 index 0000000..af4b428 --- /dev/null +++ b/Koha/Exception/Parse.pm @@ -0,0 +1,29 @@ +package Koha::Exception::Parse; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::Parse' => { + isa => 'Koha::Exception', + description => 'Parsing the given input failed', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/RemoteInvocation.pm b/Koha/Exception/RemoteInvocation.pm new file mode 100644 index 0000000..2c1033d --- /dev/null +++ b/Koha/Exception/RemoteInvocation.pm @@ -0,0 +1,29 @@ +package Koha::Exception::RemoteInvocation; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::RemoteInvocation' => { + isa => 'Koha::Exception', + description => 'Interacting with a remote process failed', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/SMSDeliveryFailure.pm b/Koha/Exception/SMSDeliveryFailure.pm new file mode 100644 index 0000000..77e3771 --- /dev/null +++ b/Koha/Exception/SMSDeliveryFailure.pm @@ -0,0 +1,29 @@ +package Koha::Exception::SMSDeliveryFailure; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::SMSDeliveryFailure' => { + isa => 'Koha::Exception', + description => 'SMS delivery was failed.', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/Search.pm b/Koha/Exception/Search.pm new file mode 100644 index 0000000..897cbd5 --- /dev/null +++ b/Koha/Exception/Search.pm @@ -0,0 +1,29 @@ +package Koha::Exception::Search; + +# Copyright 2017 Koha-Suomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::Search' => { + isa => 'Koha::Exception', + description => 'Performing the given search failed', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/SelfService.pm b/Koha/Exception/SelfService.pm new file mode 100644 index 0000000..37d5bf5 --- /dev/null +++ b/Koha/Exception/SelfService.pm @@ -0,0 +1,29 @@ +package Koha::Exception::SelfService; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::SelfService' => { + isa => 'Koha::Exception', + description => "A generic Self-Service exception type", + }, +); + +return 1; diff --git a/Koha/Exception/SelfService/BlockedBorrowerCategory.pm b/Koha/Exception/SelfService/BlockedBorrowerCategory.pm new file mode 100644 index 0000000..06a1f2d --- /dev/null +++ b/Koha/Exception/SelfService/BlockedBorrowerCategory.pm @@ -0,0 +1,17 @@ +package Koha::Exception::SelfService::BlockedBorrowerCategory; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::SelfService::BlockedBorrowerCategory' => { + isa => 'Koha::Exception::SelfService', + description => "The given borrower has an unauthorized borrower category", + }, +); + +return 1; diff --git a/Koha/Exception/SelfService/OpeningHours.pm b/Koha/Exception/SelfService/OpeningHours.pm new file mode 100644 index 0000000..272da0a --- /dev/null +++ b/Koha/Exception/SelfService/OpeningHours.pm @@ -0,0 +1,18 @@ +package Koha::Exception::SelfService::OpeningHours; + +# Copyright 2017 KohaSuomi +# +# This file is part of Koha. +# + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::SelfService::OpeningHours' => { + isa => 'Koha::Exception::SelfService', + description => "Self-service resource closed at this time. Possibly outside opening hours or otherwise library has set this resource unavailable at this specific time. Try again alter. Attached time fields in ISO8601.", + fields => ['startTime', 'endTime'], + }, +); + +return 1; diff --git a/Koha/Exception/SelfService/PermissionRevoked.pm b/Koha/Exception/SelfService/PermissionRevoked.pm new file mode 100644 index 0000000..ad77bf1 --- /dev/null +++ b/Koha/Exception/SelfService/PermissionRevoked.pm @@ -0,0 +1,17 @@ +package Koha::Exception::SelfService::PermissionRevoked; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::SelfService::PermissionRevoked' => { + isa => 'Koha::Exception::SelfService', + description => "The given borrower has got his self-service usage permission revoked", + }, +); + +return 1; diff --git a/Koha/Exception/SelfService/TACNotAccepted.pm b/Koha/Exception/SelfService/TACNotAccepted.pm new file mode 100644 index 0000000..d3df4df --- /dev/null +++ b/Koha/Exception/SelfService/TACNotAccepted.pm @@ -0,0 +1,17 @@ +package Koha::Exception::SelfService::TACNotAccepted; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::SelfService::TACNotAccepted' => { + isa => 'Koha::Exception::SelfService', + description => "Self-Service terms and conditions has not been accepted by the user in the OPAC", + }, +); + +return 1; diff --git a/Koha/Exception/SelfService/Underage.pm b/Koha/Exception/SelfService/Underage.pm new file mode 100644 index 0000000..bda3455 --- /dev/null +++ b/Koha/Exception/SelfService/Underage.pm @@ -0,0 +1,18 @@ +package Koha::Exception::SelfService::Underage; + +# Copyright 2016 KohaSuomi +# +# This file is part of Koha. +# + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::SelfService::Underage' => { + isa => 'Koha::Exception::SelfService', + description => "The given borrower is too young to access the self-service resource", + fields => ['minimumAge'], + }, +); + +return 1; diff --git a/Koha/Exception/ServiceTemporarilyUnavailable.pm b/Koha/Exception/ServiceTemporarilyUnavailable.pm new file mode 100644 index 0000000..455956e --- /dev/null +++ b/Koha/Exception/ServiceTemporarilyUnavailable.pm @@ -0,0 +1,29 @@ +package Koha::Exception::ServiceTemporarilyUnavailable; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::ServiceTemporarilyUnavailable' => { + isa => 'Koha::Exception', + description => 'Service is temporarily unavailable', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/SubroutineCall.pm b/Koha/Exception/SubroutineCall.pm new file mode 100644 index 0000000..a7c1ddd --- /dev/null +++ b/Koha/Exception/SubroutineCall.pm @@ -0,0 +1,17 @@ +package Koha::Exception::SubroutineCall; + +# Copyright 2016 Koha-Suomi Oy +# +# This file is part of Koha. +# + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::SubroutineCall' => { + isa => 'Koha::Exception', + description => 'Subroutine is called wrongly', + }, +); + +return 1; diff --git a/Koha/Exception/SystemCall.pm b/Koha/Exception/SystemCall.pm new file mode 100644 index 0000000..96e6c61 --- /dev/null +++ b/Koha/Exception/SystemCall.pm @@ -0,0 +1,29 @@ +package Koha::Exception::SystemCall; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::SystemCall' => { + isa => 'Koha::Exception', + description => 'Making a system call failed', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/UnknownObject.pm b/Koha/Exception/UnknownObject.pm new file mode 100644 index 0000000..b8a727b --- /dev/null +++ b/Koha/Exception/UnknownObject.pm @@ -0,0 +1,29 @@ +package Koha::Exception::UnknownObject; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::UnknownObject' => { + isa => 'Koha::Exception', + description => 'Object cannot be found or is not known', + }, +); + +return 1; diff --git a/Koha/Exception/UnknownProgramState.pm b/Koha/Exception/UnknownProgramState.pm new file mode 100644 index 0000000..5704f6f --- /dev/null +++ b/Koha/Exception/UnknownProgramState.pm @@ -0,0 +1,29 @@ +package Koha::Exception::UnknownProgramState; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::UnknownProgramState' => { + isa => 'Koha::Exception', + description => 'The running program has done something terribly unpredicatable', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/UnknownProtocol.pm b/Koha/Exception/UnknownProtocol.pm new file mode 100644 index 0000000..ad71578 --- /dev/null +++ b/Koha/Exception/UnknownProtocol.pm @@ -0,0 +1,29 @@ +package Koha::Exception::UnknownProtocol; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::UnknownProtocol' => { + isa => 'Koha::Exception', + description => 'Protocol is not known', + }, +); + +return 1; \ No newline at end of file diff --git a/Koha/Exception/VersionMismatch.pm b/Koha/Exception/VersionMismatch.pm new file mode 100644 index 0000000..c07a220 --- /dev/null +++ b/Koha/Exception/VersionMismatch.pm @@ -0,0 +1,29 @@ +package Koha::Exception::VersionMismatch; + +# Copyright 2015 Vaara-kirjastot +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Exception::Class ( + 'Koha::Exception::VersionMismatch' => { + isa => 'Koha::Exception', + description => 'Versions do not match', + }, +); + +return 1; \ No newline at end of file diff --git a/t/Exception.t b/t/Exception.t new file mode 100644 index 0000000..74fbc4a --- /dev/null +++ b/t/Exception.t @@ -0,0 +1,25 @@ +use Modern::Perl; +use Test::More; +use Scalar::Util qw(blessed); + +use Try::Tiny; +use Koha::Exception::UnknownProgramState; + +subtest "Throw and catch a Koha::Exception", \&tryCatch; +sub tryCatch { + eval { + + try { + Koha::Exception::UnknownProgramState->throw(error => 'Test this!'); + ok(0, 'Y U No error!'); + } catch { + is(ref($_), 'Koha::Exception::UnknownProgramState', 'Is a proper Koha::Exception'); + ok($_->isa('Koha::Exception'), 'Is a Koha::Exception subclass'); + is($_->error, 'Test this!', 'Correct error message'); + }; + + }; + ok(0, $@) if $@; +}; + +done_testing; -- 2.7.4