Skip to content

Commit

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

require_api('lang_api.php');

/* TODO: This class is currently too vague. Plugins should throw more detailed
* exceptions. Perhaps this class can be abstracted so that it can be extended
* by plugins, but handled by MantisBT core in consistent ways.
*/
class UpgradeFailed extends ExceptionAbstract {
public function __construct($pluginName, $failureReason) {
$errorMessage = lang_get(ERROR_PLUGIN_UPGRADE_FAILED, null, false);
$errorMessage = sprintf($errorMessage, $pluginName, $failureReason);
parent::__construct(ERROR_PLUGIN_UPGRADE_FAILED, $errorMessage, null);
$this->responseCode = 500;
}
}
6 changes: 1 addition & 5 deletions application/core/plugin_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
* @uses config_api.php
* @uses constant_inc.php
* @uses database_api.php
* @uses error_api.php
* @uses event_api.php
* @uses helper_api.php
* @uses history_api.php
Expand All @@ -44,7 +43,6 @@
require_api( 'config_api.php' );
require_api( 'constant_inc.php' );
require_api( 'database_api.php' );
require_api( 'error_api.php' );
require_api( 'event_api.php' );
require_api( 'helper_api.php' );
require_api( 'history_api.php' );
Expand Down Expand Up @@ -663,9 +661,7 @@ function plugin_upgrade( $p_plugin ) {
if( 2 == $t_status ) {
plugin_config_set( 'schema', $i );
} else {
error_parameters( $i );
trigger_error( ERROR_PLUGIN_UPGRADE_FAILED, ERROR );
return null;
throw new UpgradeFailed( $p_plugin->basename, $i );
}

$i++;
Expand Down

0 comments on commit 4f1b5fc

Please sign in to comment.