So I have a command(1) that is calling another command(1) (command 1 and 2 from here on in). However, if command 2 throws an exception it can't be caught by command 1 for some reason.
Does anyone know how to deal with exceptions on "command-ception"?
Here is my code:
public function handle()
{
$this->client = $this->argument('client');
try {
// Create database
$this->createClientDatabase();
$this->call('migrate', [
'--database' => $this->client,
'--path' => 'database/migrations/aca',
]);
// Import the information into the tables
} catch (Exception $e) {
$this->dropClientDatabase();
}
}
To clarify, I create a database and connection on the fly but if something fails on the migration call I end up with an empty database and no way to catch the error. If something happens within $this->call()
it simply dies and doesn't continue processing command 1.