Skip to content

Commit

Permalink
Implement ProjectNameNotUnique exception
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhicks committed Feb 25, 2012
1 parent 2712af6 commit dc784c5
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/Project/ProjectNameNotUnique.php
@@ -0,0 +1,14 @@
<?php
namespace MantisBT\Exception\Project;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

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

use MantisBT\Exception\Database\ColumnNotFound;
use MantisBT\Exception\Project\ProjectNameNotUnique;
use MantisBT\Exception\Project\ProjectNotFound;

require_api( 'bug_api.php' );
Expand Down Expand Up @@ -228,7 +229,7 @@ function project_is_name_unique( $p_name ) {
# otherwise let execution continue undisturbed
function project_ensure_name_unique( $p_name ) {
if( !project_is_name_unique( $p_name ) ) {
trigger_error( ERROR_PROJECT_NAME_NOT_UNIQUE, ERROR );
throw new ProjectNameNotUnique( $p_name );
}
}

Expand Down

0 comments on commit dc784c5

Please sign in to comment.