Skip to content

Commit

Permalink
Use proper exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Apr 1, 2022
1 parent eac5258 commit 62ebdff
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/Commands/HydeMakePageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Hyde\Framework\Commands;

use Exception;
use LaravelZero\Framework\Commands\Command;

/**
Expand Down Expand Up @@ -61,21 +62,14 @@ public function handle(): int
*/
protected function validateOptions(): void
{
$title = $this->argument('title');
$this->title = $this->argument('title');

$type = $this->option('type') ?? 'markdown';

if (!in_array($type, ['markdown', 'blade'])) {
$this->error("Invalid page type: $type");
exit(1);
throw new Exception("Invalid page type: $type", 400);
}

if (empty($title)) {
$this->error('You must specify a title for the page');
exit(1);
}

$this->title = $title;

// Set the type to the fully qualified class name
if ($type === 'markdown') {
$this->type = \Hyde\Framework\Models\MarkdownPage::class;
Expand Down

0 comments on commit 62ebdff

Please sign in to comment.