Skip to content

Commit

Permalink
Implement CategoryNotFound exception
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhicks committed Dec 18, 2011
1 parent 11647d9 commit 58e853c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
13 changes: 13 additions & 0 deletions application/MantisBT/Exception/Issue/Category/CategoryNotFound.php
@@ -0,0 +1,13 @@
<?php
namespace MantisBT\Exception\Issue\Category;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class CategoryNotFound extends ExceptionAbstract {
public function __construct() {
$errorMessage = lang_get(ERROR_CATEGORY_NOT_FOUND, null, false);
parent::__construct(ERROR_CATEGORY_NOT_FOUND, $errorMessage, null);
$this->responseCode = 400;
}
}
5 changes: 3 additions & 2 deletions application/core/category_api.php
Expand Up @@ -36,6 +36,7 @@
*/

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

require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
Expand Down Expand Up @@ -83,7 +84,7 @@ function category_exists( $p_category_id ) {
*/
function category_ensure_exists( $p_category_id ) {
if( !category_exists( $p_category_id ) ) {
trigger_error( ERROR_CATEGORY_NOT_FOUND, ERROR );
throw new CategoryNotFound();
}
}

Expand Down Expand Up @@ -291,7 +292,7 @@ function category_get_row( $p_category_id ) {
$result = db_query_bound( $query, array( $c_category_id ) );
$row = db_fetch_array( $result );
if( !$row ) {
trigger_error( ERROR_CATEGORY_NOT_FOUND, ERROR );
throw new CategoryNotFound();
}

$g_category_cache[$p_category_id] = $row;
Expand Down

0 comments on commit 58e853c

Please sign in to comment.