Skip to content

Commit

Permalink
Implement TagNameNotUnique exception
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhicks committed Dec 18, 2011
1 parent d6849a3 commit b2703b0
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/Tag/TagNameNotUnique.php
@@ -0,0 +1,14 @@
<?php
namespace MantisBT\Exception\Tag;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

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

use MantisBT\Exception\Database\ColumnNotFound;
use MantisBT\Exception\Tag\TagNameNotUnique;
use MantisBT\Exception\Tag\TagNotFound;

require_api( 'access_api.php' );
Expand Down Expand Up @@ -104,7 +105,7 @@ function tag_is_unique( $p_name ) {
*/
function tag_ensure_unique( $p_name ) {
if( !tag_is_unique( $p_name ) ) {
trigger_error( ERROR_TAG_DUPLICATE, ERROR );
throw new TagNameNotUnique( $p_name );
}
}

Expand Down

0 comments on commit b2703b0

Please sign in to comment.