Skip to content

Commit

Permalink
Implement InstallationFailed exception
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhicks committed Jan 15, 2012
1 parent b1a07ed commit 55c8c13
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 18 additions & 0 deletions application/MantisBT/Exception/Plugin/InstallationFailed.php
@@ -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 InstallationFailed extends ExceptionAbstract {
public function __construct($pluginName, $failureReason) {
$errorMessage = lang_get(ERROR_PLUGIN_INSTALL_FAILED, null, false);
$errorMessage = sprintf($errorMessage, $pluginName, $failureReason);
parent::__construct(ERROR_PLUGIN_INSTALL_FAILED, $errorMessage, null);
$this->responseCode = 500;
}
}
6 changes: 3 additions & 3 deletions public/plugins/XmlImportExport/XmlImportExport.php
Expand Up @@ -23,6 +23,8 @@
* @link http://www.mantisbt.org
*/

use MantisBT\Exception\Plugin\InstallationFailed;

/**
* XmlImportExportPlugin Class
*/
Expand Down Expand Up @@ -68,9 +70,7 @@ function export_issues_menu( ) {
function install() {
$result = extension_loaded("xmlreader") && extension_loaded("xmlwriter");
if ( ! $result ) {
#\todo returning false should trigger some error reporting, needs rethinking error_api
error_parameters( plugin_lang_get( 'error_no_xml' ) );
trigger_error( ERROR_PLUGIN_INSTALL_FAILED, ERROR );
throw new InstallationFailed( plugin_lang_get( 'title' ), plugin_lang_get( 'error_no_xml' ) );
}
return $result;
}
Expand Down

0 comments on commit 55c8c13

Please sign in to comment.