Skip to content

Commit

Permalink
Implement CategoryNotFoundForProject exception
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhicks committed May 7, 2012
1 parent b254fef commit 2580cc3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
@@ -0,0 +1,14 @@
<?php
namespace MantisBT\Exception\Issue\Category;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class CategoryNotFoundForProject extends ExceptionAbstract {
public function __construct($categoryName, $projectName) {
$errorMessage = lang_get(ERROR_CATEGORY_NOT_FOUND_FOR_PROJECT, null, false);
$errorMessage = sprintf($errorMessage, $categoryName, $projectName);
parent::__construct(ERROR_CATEGORY_NOT_FOUND_FOR_PROJECT, $errorMessage, null);
$this->responseCode = 400;
}
}
4 changes: 2 additions & 2 deletions application/core/category_api.php
Expand Up @@ -37,6 +37,7 @@

use MantisBT\Exception\Field\EmptyField;
use MantisBT\Exception\Issue\Category\CategoryNotFound;
use MantisBT\Exception\Issue\Category\CategoryNotFoundForProject;

require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
Expand Down Expand Up @@ -559,8 +560,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 ) {
error_parameters( $p_category_name, $t_project_name );
trigger_error( ERROR_CATEGORY_NOT_FOUND_FOR_PROJECT, ERROR );
throw new CategoryNotFoundForProject( $p_category_name, $t_project_name );
} else {
return false;
}
Expand Down

0 comments on commit 2580cc3

Please sign in to comment.