Skip to content

Commit

Permalink
Implement RevisionNotFound exception
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhicks committed Sep 17, 2011
1 parent a556aa9 commit 6938b1d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 14 additions & 0 deletions application/MantisBT/Exception/Issue/Revision/RevisionNotFound.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace MantisBT\Exception\Issue\Revision;
use MantisBT\Exception\ExceptionAbstract;

require_api('lang_api.php');

class RevisionNotFound extends ExceptionAbstract {
public function __construct($revisionID) {
$errorMessage = lang_get(ERROR_BUG_REVISION_NOT_FOUND, null, false);
$errorMessage = sprintf($errorMessage, $revisionID);
parent::__construct(ERROR_BUG_REVISION_NOT_FOUND, $errorMessage, null);
$this->responseCode = 400;
}
}
6 changes: 4 additions & 2 deletions application/core/bug_revision_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
* @uses database_api.php
*/

use MantisBT\Exception\Issue\Revision\RevisionNotFound;

require_api( 'constant_inc.php' );
require_api( 'database_api.php' );

Expand Down Expand Up @@ -113,7 +115,7 @@ function bug_revision_get( $p_revision_id ) {

$t_row = db_fetch_array( $t_result );
if ( !$t_row ) {
trigger_error( ERROR_BUG_REVISION_NOT_FOUND, ERROR );
throw new RevisionNotFound( $p_revision_id );
}

return $t_row;
Expand Down Expand Up @@ -306,7 +308,7 @@ function bug_revision_like( $p_rev_id ) {
$t_row = db_fetch_array( $t_result );

if ( !$t_row ) {
trigger_error( ERROR_BUG_REVISION_NOT_FOUND, ERROR );
throw new RevisionNotFound( $p_rev_id );
}

$t_bug_id = $t_row['bug_id'];
Expand Down

0 comments on commit 6938b1d

Please sign in to comment.