Let’s say I’m coding a command. How would I stop it completely in the middle of it running?
Example:
JavaScript
x
public function handle()
{
if (!$this->good_times) {
$this->error('Bad times');
$this->exit();
}
// continue command stuff
}
I have tried:
JavaScript
throw new RuntimeException('Bad times');
But that dumps a bunch of ugliness in the terminal.
Advertisement
Answer
Just use a return
statement instead of throwing an exception. Like…
JavaScript
public function handle()
{
if (!$this->good_times) {
$this->error('Bad times');
// $this->exit();
// throw new RuntimeException('Bad times');
return;
}
// ...
}