Permalink
Browse files

Further work on Exceptions

  • Loading branch information...
grangeway committed Oct 21, 2012
1 parent 6c79f5d commit 82d615b8e320760495dd86685b411ed309de3b86
Showing with 1,587 additions and 54 deletions.
  1. +2 −1 core/bug_api.php
  2. +2 −1 core/category_api.php
  3. +48 −0 core/classes/Exception/Access/InsufficientAccessLevel.class.php
  4. +48 −0 core/classes/Exception/Configuration/OptionInvalidValue.class.php
  5. +48 −0 core/classes/Exception/Configuration/OptionNotFound.class.php
  6. +48 −0 core/classes/Exception/CustomField/NotLinkedToProject.class.php
  7. +48 −0 core/classes/Exception/File/FileNoUpload.class.php
  8. +48 −0 core/classes/Exception/File/FileTooBig.class.php
  9. +48 −0 core/classes/Exception/File/FileUploadFailed.class.php
  10. +48 −0 core/classes/Exception/Filter/FilterNotFound.class.php
  11. +48 −0 core/classes/Exception/Issue/Tag/TagAlreadyAttached.class.php
  12. +48 −0 core/classes/Exception/Issue/Tag/TagNotAttached.class.php
  13. +48 −0 core/classes/Exception/Issue/Version/VersionDuplicate.class.php
  14. +48 −0 core/classes/Exception/Issue/Version/VersionNotFound.class.php
  15. +48 −0 core/classes/Exception/Language/LanguageStringNotFound.class.php
  16. +48 −0 core/classes/Exception/PHP/HeadersAlreadySent.class.php
  17. +48 −0 core/classes/Exception/Plugin/EventNotDeclared.class.php
  18. +48 −0 core/classes/Exception/Plugin/PluginAlreadyInstalled.class.php
  19. +48 −0 core/classes/Exception/Plugin/PluginUpgradeFailed.class.php
  20. +48 −0 core/classes/Exception/Project/Category/CategoryNotFound.class.php
  21. +48 −0 core/classes/Exception/Project/ProjectNameNotUnique.class.php
  22. +48 −0 core/classes/Exception/Project/ProjectNameNotValid.class.php
  23. +48 −0 core/classes/Exception/Project/ProjectNotFound.class.php
  24. +48 −0 core/classes/Exception/Project/RecursiveHierarchyNotAllowed.class.php
  25. +48 −0 core/classes/Exception/Security/CSPRNGNotAvailable.class.php
  26. +48 −0 core/classes/Exception/Security/MasterSaltInvalid.class.php
  27. +48 −0 core/classes/Exception/Session/SessionHandlerInvalid.class.php
  28. +48 −0 core/classes/Exception/Session/SessionVariableNotFound.class.php
  29. +48 −0 core/classes/Exception/Sponsorship/SponsorshipNotFound.class.php
  30. +48 −0 core/classes/Exception/Tag/TagNameNotValid.class.php
  31. +48 −0 core/classes/Exception/Tag/TagNotFound.class.php
  32. +48 −0 core/classes/Exception/Token/TokenNotFound.class.php
  33. +48 −0 core/classes/Exception/Validation/DateFormatInvalid.class.php
  34. +2 −1 core/classes/MantisBug.class.php
  35. +2 −1 core/classes/MantisLanguage.class.php
  36. +2 −1 core/config_api.php
  37. +4 −2 core/crypto_api.php
  38. +4 −2 core/custom_field_api.php
  39. +1 −1 core/database_api.php
  40. +2 −1 core/email_api.php
  41. +4 −2 core/event_api.php
  42. +7 −4 core/file_api.php
  43. +2 −1 core/filter_api.php
  44. +6 −3 core/gpc_api.php
  45. +5 −4 core/helper_api.php
  46. +5 −3 core/plugin_api.php
  47. +3 −2 core/print_api.php
  48. +11 −6 core/project_api.php
  49. +2 −1 core/project_hierarchy_api.php
  50. +4 −2 core/session_api.php
  51. +2 −1 core/sponsorship_api.php
  52. +10 −5 core/tag_api.php
  53. +2 −1 core/tokens_api.php
  54. +3 −2 core/user_api.php
  55. +10 −5 core/version_api.php
  56. +2 −1 plugins/XmlImportExport/ImportXml/Issue.php
View
@@ -739,10 +739,11 @@ function bug_set_field( $p_bug_id, $p_field_name, $p_value ) {
* @return null
* @access public
* @uses database_api.php
+ * @throws MantisBT\Exception\Access\InsufficientAccessLevel
*/
function bug_assign( $p_bug, $p_user_id, $p_bugnote_text = '', $p_bugnote_private = false ) {
if(( $p_user_id != NO_USER ) && !access_has_bug_level( config_get( 'handle_bug_threshold' ), $p_bug->id, $p_user_id ) ) {
- throw new MantisBT\Exception\User_Does_Not_Have_Req_Access();
+ throw new MantisBT\Exception\Access\InsufficientAccessLevel();
}
# extract current information into history variables
View
@@ -531,6 +531,7 @@ function category_get_name( $p_category_id ) {
* @param bool $p_trigger_errors trigger error on failure
* @return bool
* @access public
+ * @throws MantisBT\Exception\Project\Category\CategoryNotFound
*/
function category_get_id_by_name( $p_category_name, $p_project_id, $p_trigger_errors = true ) {
$t_project_name = project_get_name( $p_project_id );
@@ -540,7 +541,7 @@ function category_get_id_by_name( $p_category_name, $p_project_id, $p_trigger_er
$t_id = db_result( $t_result );
if( $t_id ) {
if( $p_trigger_errors ) {
- throw new MantisBT\Exception\Category_Not_Found_For_Project( $p_category_name, $t_project_name );
+ throw new MantisBT\Exception\Project\Category\CategoryNotFound( $p_category_name, $t_project_name );
} else {
return false;
}
@@ -0,0 +1,48 @@
+<?php
+/**
+ * MantisBT - A PHP based bugtracking system
+ *
+ * MantisBT 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.
+ *
+ * MantisBT 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 MantisBT. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @copyright Copyright (C) 2002 - 2012 MantisBT Team - mantisbt-dev@lists.sourceforge.
+ * @link http://www.mantisbt.org
+ * @package MantisBT
+ */
+
+namespace MantisBT\Exception\Access;
+use MantisBT\Exception\ExceptionAbstract;
+
+/**
+ * Insufficient Access Level Exception
+ * @package MantisBT
+ * @subpackage classes
+ */
+class InsufficientAccessLevel extends ExceptionAbstract
+{
+ /**
+ * Constructor
+ * @param array $p_parameters parameters
+ * @param \Exception previous exception
+ */
+ public function __construct($p_parameters = null, \Exception $p_previous = null)
+ {
+ if ($p_parameters === null) {
+ $t_message = lang_get('exception_user_does_not_have_req_access');
+ } else {
+ $t_message = vsprintf( lang_get('exception_user_does_not_have_req_access'), $p_parameters);
+ }
+ parent::__construct($t_message, 401, $p_previous);
+ }
+}
+?>
@@ -0,0 +1,48 @@
+<?php
+/**
+ * MantisBT - A PHP based bugtracking system
+ *
+ * MantisBT 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.
+ *
+ * MantisBT 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 MantisBT. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @copyright Copyright (C) 2002 - 2012 MantisBT Team - mantisbt-dev@lists.sourceforge.
+ * @link http://www.mantisbt.org
+ * @package MantisBT
+ */
+
+namespace MantisBT\Exception\Configuration;
+use MantisBT\Exception\ExceptionAbstract;
+
+/**
+ * Configuration Option Invalid Value
+ * @package MantisBT
+ * @subpackage classes
+ */
+class OptionInvalidValue extends ExceptionAbstract
+{
+ /**
+ * Constructor
+ * @param array $p_parameters parameters
+ * @param \Exception previous exception
+ */
+ public function __construct($p_parameters = null, \Exception $p_previous = null)
+ {
+ if ($p_parameters === null) {
+ $t_message = lang_get('exception_config_opt_invalid');
+ } else {
+ $t_message = vsprintf( lang_get('exception_config_opt_invalid'), $p_parameters);
+ }
+ parent::__construct($t_message, 500, $p_previous);
+ }
+}
+?>
@@ -0,0 +1,48 @@
+<?php
+/**
+ * MantisBT - A PHP based bugtracking system
+ *
+ * MantisBT 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.
+ *
+ * MantisBT 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 MantisBT. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @copyright Copyright (C) 2002 - 2012 MantisBT Team - mantisbt-dev@lists.sourceforge.
+ * @link http://www.mantisbt.org
+ * @package MantisBT
+ */
+
+namespace MantisBT\Exception\Configuration;
+use MantisBT\Exception\ExceptionAbstract;
+
+/**
+ * Configuration Option Not Found
+ * @package MantisBT
+ * @subpackage classes
+ */
+class OptionNotFound extends ExceptionAbstract
+{
+ /**
+ * Constructor
+ * @param array $p_parameters parameters
+ * @param \Exception previous exception
+ */
+ public function __construct($p_parameters = null, \Exception $p_previous = null)
+ {
+ if ($p_parameters === null) {
+ $t_message = lang_get('exception_config_opt_not_found');
+ } else {
+ $t_message = vsprintf( lang_get('exception_config_opt_not_found'), $p_parameters);
+ }
+ parent::__construct($t_message, 500, $p_previous);
+ }
+}
+?>
@@ -0,0 +1,48 @@
+<?php
+/**
+ * MantisBT - A PHP based bugtracking system
+ *
+ * MantisBT 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.
+ *
+ * MantisBT 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 MantisBT. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @copyright Copyright (C) 2002 - 2012 MantisBT Team - mantisbt-dev@lists.sourceforge.
+ * @link http://www.mantisbt.org
+ * @package MantisBT
+ */
+
+namespace MantisBT\Exception\CustomField;
+use MantisBT\Exception\ExceptionAbstract;
+
+/**
+ * Custom Field Not Linked To Project Exception
+ * @package MantisBT
+ * @subpackage classes
+ */
+class NotLinkedToProject extends ExceptionAbstract
+{
+ /**
+ * Constructor
+ * @param array $p_parameters parameters
+ * @param \Exception previous exception
+ */
+ public function __construct($p_parameters = null, \Exception $p_previous = null)
+ {
+ if ($p_parameters === null) {
+ $t_message = lang_get('exception_custom_field_not_linked_to_project');
+ } else {
+ $t_message = vsprintf( lang_get('exception_custom_field_not_linked_to_project'), $p_parameters);
+ }
+ parent::__construct($t_message, 500, $p_previous);
+ }
+}
+?>
@@ -0,0 +1,48 @@
+<?php
+/**
+ * MantisBT - A PHP based bugtracking system
+ *
+ * MantisBT 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.
+ *
+ * MantisBT 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 MantisBT. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @copyright Copyright (C) 2002 - 2012 MantisBT Team - mantisbt-dev@lists.sourceforge.
+ * @link http://www.mantisbt.org
+ * @package MantisBT
+ */
+
+namespace MantisBT\Exception\File;
+use MantisBT\Exception\ExceptionAbstract;
+
+/**
+ * File No Upload Exception
+ * @package MantisBT
+ * @subpackage classes
+ */
+class FileNoUpload extends ExceptionAbstract
+{
+ /**
+ * Constructor
+ * @param array $p_parameters parameters
+ * @param \Exception previous exception
+ */
+ public function __construct($p_parameters = null, \Exception $p_previous = null)
+ {
+ if ($p_parameters === null) {
+ $t_message = lang_get('exception_file_no_upload_failure');
+ } else {
+ $t_message = vsprintf( lang_get('exception_file_no_upload_failure'), $p_parameters);
+ }
+ parent::__construct($t_message, 500, $p_previous);
+ }
+}
+?>
@@ -0,0 +1,48 @@
+<?php
+/**
+ * MantisBT - A PHP based bugtracking system
+ *
+ * MantisBT 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.
+ *
+ * MantisBT 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 MantisBT. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @copyright Copyright (C) 2002 - 2012 MantisBT Team - mantisbt-dev@lists.sourceforge.
+ * @link http://www.mantisbt.org
+ * @package MantisBT
+ */
+
+namespace MantisBT\Exception\File;
+use MantisBT\Exception\ExceptionAbstract;
+
+/**
+ * File Too Bug Exception
+ * @package MantisBT
+ * @subpackage classes
+ */
+class FileTooBig extends ExceptionAbstract
+{
+ /**
+ * Constructor
+ * @param array $p_parameters parameters
+ * @param \Exception previous exception
+ */
+ public function __construct($p_parameters = null, \Exception $p_previous = null)
+ {
+ if ($p_parameters === null) {
+ $t_message = lang_get('exception_file_too_big');
+ } else {
+ $t_message = vsprintf( lang_get('exception_file_too_big'), $p_parameters);
+ }
+ parent::__construct($t_message, 500, $p_previous);
+ }
+}
+?>
@@ -0,0 +1,48 @@
+<?php
+/**
+ * MantisBT - A PHP based bugtracking system
+ *
+ * MantisBT 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.
+ *
+ * MantisBT 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 MantisBT. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @copyright Copyright (C) 2002 - 2012 MantisBT Team - mantisbt-dev@lists.sourceforge.
+ * @link http://www.mantisbt.org
+ * @package MantisBT
+ */
+
+namespace MantisBT\Exception\File;
+use MantisBT\Exception\ExceptionAbstract;
+
+/**
+ * File Upload Failed Exception
+ * @package MantisBT
+ * @subpackage classes
+ */
+class FileUploadFailed extends ExceptionAbstract
+{
+ /**
+ * Constructor
+ * @param array $p_parameters parameters
+ * @param \Exception previous exception
+ */
+ public function __construct($p_parameters = null, \Exception $p_previous = null)
+ {
+ if ($p_parameters === null) {
+ $t_message = lang_get('exception_upload_failure');
+ } else {
+ $t_message = vsprintf( lang_get('exception_upload_failure'), $p_parameters);
+ }
+ parent::__construct($t_message, 500, $p_previous);
+ }
+}
+?>
Oops, something went wrong.

0 comments on commit 82d615b

Please sign in to comment.