Skip to content

Commit

Permalink
Implement CommentNotFound exception
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhicks committed Jan 15, 2012
1 parent 5f34acf commit 12e26e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions application/MantisBT/Exception/Issue/Comment/CommentNotFound.php
@@ -0,0 +1,14 @@
<?php
namespace MantisBT\Exception\Issue\Comment;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class CommentNotFound extends ExceptionAbstract {
public function __construct($commentID) {
$errorMessage = lang_get(ERROR_BUGNOTE_NOT_FOUND, null, false);
$errorMessage = sprintf($errorMessage, $commentID);
parent::__construct(ERROR_BUGNOTE_NOT_FOUND, $errorMessage, null);
$this->responseCode = 400;
}
}
3 changes: 2 additions & 1 deletion application/core/bugnote_api.php
Expand Up @@ -42,6 +42,7 @@

use MantisBT\Exception\Database\ColumnNotFound;
use MantisBT\Exception\Field\EmptyField;
use MantisBT\Exception\Issue\Comment\CommentNotFound;

require_api( 'access_api.php' );
require_api( 'authentication_api.php' );
Expand Down Expand Up @@ -107,7 +108,7 @@ function bugnote_exists( $p_bugnote_id ) {
*/
function bugnote_ensure_exists( $p_bugnote_id ) {
if( !bugnote_exists( $p_bugnote_id ) ) {
trigger_error( ERROR_BUGNOTE_NOT_FOUND, ERROR );
throw new CommentNotFound( $p_bugnote_id );
}
}

Expand Down

0 comments on commit 12e26e9

Please sign in to comment.