From b4c56d131e0a33a93ec027659892e3bb541455a0 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 26 Jun 2012 13:32:28 -0400 Subject: [PATCH] Defined exceptions. --- module/VuFind/src/VuFind/Exception/Auth.php | 41 +++++++++++ module/VuFind/src/VuFind/Exception/Date.php | 41 +++++++++++ .../src/VuFind/Exception/FileAccess.php | 41 +++++++++++ .../VuFind/src/VuFind/Exception/Forbidden.php | 41 +++++++++++ module/VuFind/src/VuFind/Exception/ILS.php | 41 +++++++++++ .../src/VuFind/Exception/ListPermission.php | 41 +++++++++++ .../src/VuFind/Exception/LoginRequired.php | 41 +++++++++++ module/VuFind/src/VuFind/Exception/Mail.php | 41 +++++++++++ .../src/VuFind/Exception/MissingField.php | 41 +++++++++++ .../src/VuFind/Exception/RecordMissing.php | 41 +++++++++++ .../src/VuFind/Exception/SessionExpired.php | 41 +++++++++++ module/VuFind/src/VuFind/Exception/Solr.php | 72 +++++++++++++++++++ 12 files changed, 523 insertions(+) create mode 100644 module/VuFind/src/VuFind/Exception/Auth.php create mode 100644 module/VuFind/src/VuFind/Exception/Date.php create mode 100644 module/VuFind/src/VuFind/Exception/FileAccess.php create mode 100644 module/VuFind/src/VuFind/Exception/Forbidden.php create mode 100644 module/VuFind/src/VuFind/Exception/ILS.php create mode 100644 module/VuFind/src/VuFind/Exception/ListPermission.php create mode 100644 module/VuFind/src/VuFind/Exception/LoginRequired.php create mode 100644 module/VuFind/src/VuFind/Exception/Mail.php create mode 100644 module/VuFind/src/VuFind/Exception/MissingField.php create mode 100644 module/VuFind/src/VuFind/Exception/RecordMissing.php create mode 100644 module/VuFind/src/VuFind/Exception/SessionExpired.php create mode 100644 module/VuFind/src/VuFind/Exception/Solr.php diff --git a/module/VuFind/src/VuFind/Exception/Auth.php b/module/VuFind/src/VuFind/Exception/Auth.php new file mode 100644 index 00000000000..aea31d38b56 --- /dev/null +++ b/module/VuFind/src/VuFind/Exception/Auth.php @@ -0,0 +1,41 @@ +<?php +/** + * Authentication Exception + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +namespace VuFind\Exception; + +/** + * Authentication Exception + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +class Auth extends \Exception +{ +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Exception/Date.php b/module/VuFind/src/VuFind/Exception/Date.php new file mode 100644 index 00000000000..acbb01a97cb --- /dev/null +++ b/module/VuFind/src/VuFind/Exception/Date.php @@ -0,0 +1,41 @@ +<?php +/** + * Date Exception + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +namespace VuFind\Exception; + +/** + * Date Exception + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +class Date extends \Exception +{ +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Exception/FileAccess.php b/module/VuFind/src/VuFind/Exception/FileAccess.php new file mode 100644 index 00000000000..fa96a6c6c1c --- /dev/null +++ b/module/VuFind/src/VuFind/Exception/FileAccess.php @@ -0,0 +1,41 @@ +<?php +/** + * File Access Exception + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +namespace VuFind\Exception; + +/** + * File Access Exception + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +class FileAccess extends \Exception +{ +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Exception/Forbidden.php b/module/VuFind/src/VuFind/Exception/Forbidden.php new file mode 100644 index 00000000000..ba218cea3ba --- /dev/null +++ b/module/VuFind/src/VuFind/Exception/Forbidden.php @@ -0,0 +1,41 @@ +<?php +/** + * "Forbidden Access" Exception + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +namespace VuFind\Exception; + +/** + * "Forbidden Access" Exception + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +class Forbidden extends \Exception +{ +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Exception/ILS.php b/module/VuFind/src/VuFind/Exception/ILS.php new file mode 100644 index 00000000000..636cba14430 --- /dev/null +++ b/module/VuFind/src/VuFind/Exception/ILS.php @@ -0,0 +1,41 @@ +<?php +/** + * ILS Exception + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +namespace VuFind\Exception; + +/** + * ILS Exception + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +class ILS extends \Exception +{ +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Exception/ListPermission.php b/module/VuFind/src/VuFind/Exception/ListPermission.php new file mode 100644 index 00000000000..a97ec8647de --- /dev/null +++ b/module/VuFind/src/VuFind/Exception/ListPermission.php @@ -0,0 +1,41 @@ +<?php +/** + * List Permission Exception + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +namespace VuFind\Exception; + +/** + * List Permission Exception + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +class ListPermission extends \Exception +{ +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Exception/LoginRequired.php b/module/VuFind/src/VuFind/Exception/LoginRequired.php new file mode 100644 index 00000000000..d8540a5cd0b --- /dev/null +++ b/module/VuFind/src/VuFind/Exception/LoginRequired.php @@ -0,0 +1,41 @@ +<?php +/** + * Login Required Exception + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +namespace VuFind\Exception; + +/** + * Login Required Exception + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +class LoginRequired extends \Exception +{ +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Exception/Mail.php b/module/VuFind/src/VuFind/Exception/Mail.php new file mode 100644 index 00000000000..2c9f02abd3f --- /dev/null +++ b/module/VuFind/src/VuFind/Exception/Mail.php @@ -0,0 +1,41 @@ +<?php +/** + * Mail Exception + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +namespace VuFind\Exception; + +/** + * Mail Exception + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +class Mail extends \Exception +{ +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Exception/MissingField.php b/module/VuFind/src/VuFind/Exception/MissingField.php new file mode 100644 index 00000000000..21b54be5cd1 --- /dev/null +++ b/module/VuFind/src/VuFind/Exception/MissingField.php @@ -0,0 +1,41 @@ +<?php +/** + * Missing Field Exception + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +namespace VuFind\Exception; + +/** + * Missing Field Exception + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +class MissingField extends \Exception +{ +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Exception/RecordMissing.php b/module/VuFind/src/VuFind/Exception/RecordMissing.php new file mode 100644 index 00000000000..fdb3571792b --- /dev/null +++ b/module/VuFind/src/VuFind/Exception/RecordMissing.php @@ -0,0 +1,41 @@ +<?php +/** + * Record Missing Exception + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +namespace VuFind\Exception; + +/** + * Record Missing Exception + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +class RecordMissing extends \Exception +{ +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Exception/SessionExpired.php b/module/VuFind/src/VuFind/Exception/SessionExpired.php new file mode 100644 index 00000000000..92180190d0b --- /dev/null +++ b/module/VuFind/src/VuFind/Exception/SessionExpired.php @@ -0,0 +1,41 @@ +<?php +/** + * Session Expired Exception + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +namespace VuFind\Exception; + +/** + * Session Expired Exception + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://vufind.org/wiki/system_classes#index_interface Wiki + */ +class SessionExpired extends \Exception +{ +} \ No newline at end of file diff --git a/module/VuFind/src/VuFind/Exception/Solr.php b/module/VuFind/src/VuFind/Exception/Solr.php new file mode 100644 index 00000000000..a82293cf824 --- /dev/null +++ b/module/VuFind/src/VuFind/Exception/Solr.php @@ -0,0 +1,72 @@ +<?php +/** + * Solr Exception + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFind\Exception; + +/** + * Solr Exception + * + * @category VuFind2 + * @package Exceptions + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class Solr extends \Exception +{ + /** + * Is this exception caused by a Solr parse error? + * + * @return bool + */ + public function isParseError() + { + $error = $this->getMessage(); + if (stristr($error, 'org.apache.lucene.queryParser.ParseException') + || stristr($error, 'undefined field') + ) { + return true; + } + return false; + } + + /** + * Is this exception caused by a missing browse index? + * + * @return bool + */ + public function isMissingBrowseIndex() + { + $error = $this->getMessage(); + if (strstr($error, 'does not exist') || strstr($error, 'no such table') + || strstr($error, 'couldn\'t find a browse index') + ) { + return true; + } + return false; + } +} \ No newline at end of file -- GitLab