From ea6c6f3026adce1f0eecf58752f7ae01494d60ed Mon Sep 17 00:00:00 2001 From: Lari Taskula Date: Fri, 17 Feb 2017 14:34:42 +0200 Subject: [PATCH] Bug 18137: Add useful Koha::Exceptions Signed-off-by: Olli-Antti Kivilahti Signed-off-by: Josef Moravec Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- Koha/Exceptions.pm | 9 +++++++++ Koha/Exceptions/Authentication.pm | 21 +++++++++++++++++++++ Koha/Exceptions/Authorization.pm | 18 ++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 Koha/Exceptions/Authentication.pm create mode 100644 Koha/Exceptions/Authorization.pm diff --git a/Koha/Exceptions.pm b/Koha/Exceptions.pm index 60b9e6adfc..528a15106b 100644 --- a/Koha/Exceptions.pm +++ b/Koha/Exceptions.pm @@ -8,6 +8,11 @@ use Exception::Class ( 'Koha::Exceptions::Exception' => { description => 'Something went wrong!', }, + 'Koha::Exceptions::BadParameter' => { + isa => 'Koha::Exceptions::Exception', + description => 'Bad parameter was given', + fields => ["parameter"], + }, 'Koha::Exceptions::DuplicateObject' => { isa => 'Koha::Exceptions::Exception', description => 'Same object already exists', @@ -32,6 +37,10 @@ use Exception::Class ( isa => 'Koha::Exceptions::Exception', description => 'General problem adding a library limit' }, + 'Koha::Exceptions::UnderMaintenance' => { + isa => 'Koha::Exceptions::Exception', + description => 'Koha is under maintenance.' + }, # Virtualshelves exceptions 'Koha::Exceptions::Virtualshelves::DuplicateObject' => { isa => 'Koha::Exceptions::DuplicateObject', diff --git a/Koha/Exceptions/Authentication.pm b/Koha/Exceptions/Authentication.pm new file mode 100644 index 0000000000..74688ab6fb --- /dev/null +++ b/Koha/Exceptions/Authentication.pm @@ -0,0 +1,21 @@ +package Koha::Exceptions::Authentication; + +use Modern::Perl; + +use Exception::Class ( + + 'Koha::Exceptions::Authentication' => { + description => 'Something went wrong!', + }, + 'Koha::Exceptions::Authentication::Required' => { + isa => 'Koha::Exceptions::Authentication', + description => 'Authentication required' + }, + 'Koha::Exceptions::Authentication::SessionExpired' => { + isa => 'Koha::Exceptions::Authentication', + description => 'Session has been expired', + }, + +); + +1; diff --git a/Koha/Exceptions/Authorization.pm b/Koha/Exceptions/Authorization.pm new file mode 100644 index 0000000000..a3c625aca8 --- /dev/null +++ b/Koha/Exceptions/Authorization.pm @@ -0,0 +1,18 @@ +package Koha::Exceptions::Authorization; + +use Modern::Perl; + +use Exception::Class ( + + 'Koha::Exceptions::Authorization' => { + description => 'Something went wrong!', + }, + 'Koha::Exceptions::Authorization::Unauthorized' => { + isa => 'Koha::Exceptions::Authorization', + description => 'Unauthorized', + fields => ['required_permissions'] + }, + +); + +1; -- 2.39.5