Skip to content

Commit

Permalink
added showing user errors by catching exceptions caused by user mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Sep 8, 2015
1 parent 53fe95b commit 7001f7e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
11 changes: 10 additions & 1 deletion bin/hidev
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,16 @@ $application = new hidev\base\Application([
],
]);

$exitCode = $application->run();
try {
$exitCode = $application->run();
} catch (Exception $e) {
if ($e instanceof \yii\base\InvalidParamException || $e instanceof \yii\console\Exception) {
Yii::error($e->getMessage());
$exitCode = 1;
} else {
throw $e;
}
}
exit($exitCode);

function d ()
Expand Down
2 changes: 1 addition & 1 deletion src/goals/InitGoal.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function actionPerform($name, $template = '.hidev/config')
{
list($vendor, $package) = explode('/', $name, 2);
if (!$package || !$vendor) {
throw new InvalidParamException('No vendor/package given');
throw new InvalidParamException('Wrong vendor/package given: ' . $name);
}
$this->vendor = $vendor;
$this->package = $package;
Expand Down
5 changes: 4 additions & 1 deletion src/handlers/BaseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Yii;
use yii\helpers\ArrayHelper;
use yii\base\InvalidConfigException;

/**
* Base Handler.
Expand Down Expand Up @@ -57,10 +58,12 @@ public function getView()
* @param array $data
*
* @return string file content
*
* @throws InvalidConfigException
*/
public function renderPrepared(array $data)
{
throw new InvalidParamException('Render not available');
throw new InvalidConfigException('Render not available');
}

/**
Expand Down

0 comments on commit 7001f7e

Please sign in to comment.