Skip to content

Commit

Permalink
Implement ColumnInvalid exception
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhicks committed Feb 25, 2012
1 parent c43a61f commit 8fc3a7f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 14 additions & 0 deletions application/MantisBT/Exception/Column/ColumnInvalid.php
@@ -0,0 +1,14 @@
<?php
namespace MantisBT\Exception\Column;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class ColumnInvalid extends ExceptionAbstract {
public function __construct($columnSetName, $invalidColumnName) {
$errorMessage = lang_get(ERROR_COLUMNS_INVALID, null, false);
$errorMessage = sprintf($errorMessage, $columnSetName, $invalidColumnName);
parent::__construct(ERROR_COLUMNS_INVALID, $errorMessage, null);
$this->responseCode = 400;
}
}
6 changes: 3 additions & 3 deletions application/core/columns_api.php
Expand Up @@ -43,6 +43,8 @@
* @uses string_api.php
*/

use MantisBT\Exception\Column\ColumnInvalid;

require_api( 'access_api.php' );
require_api( 'bug_api.php' );
require_api( 'category_api.php' );
Expand Down Expand Up @@ -372,9 +374,7 @@ function columns_ensure_valid( $p_field_name, $p_columns_to_validate, $p_columns
# Check for invalid fields
foreach( $p_columns_to_validate as $t_column ) {
if( !in_array( utf8_strtolower( $t_column ), $t_columns_all_lower ) ) {
error_parameters( $p_field_name, $t_column );
trigger_error( ERROR_COLUMNS_INVALID, ERROR );
return false;
throw new ColumnInvalid( $p_field_name, $t_column );
}
}

Expand Down

0 comments on commit 8fc3a7f

Please sign in to comment.