From 5e517a5a29ef6c5bbc6fa55c4e3b0e5176b3f837 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 --- 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 dd8647b..9adc06e 100644 --- a/Koha/Exceptions.pm +++ b/Koha/Exceptions.pm @@ -9,6 +9,11 @@ use Exception::Class ( 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', @@ -21,6 +26,10 @@ use Exception::Class ( isa => 'Koha::Exceptions::Exception', description => 'A required parameter is missing' }, + '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 0000000..74688ab --- /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 0000000..a3c625a --- /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; -- 1.9.1