594d0eb222
* Check Aircraft Availability before Prefile Check if the aircraft is available for flight (State : Parked / On Ground). If not throw new exception AircraftNotAvailable * Add Exception AircraftNotAvailable exception, used by PirepService during prefile checks.
39 lines
732 B
PHP
39 lines
732 B
PHP
<?php
|
|
|
|
namespace App\Exceptions;
|
|
|
|
use App\Models\Aircraft;
|
|
|
|
class AircraftNotAvailable extends AbstractHttpException
|
|
{
|
|
public const MESSAGE = 'The aircraft is not available for flight';
|
|
|
|
private $aircraft;
|
|
|
|
public function __construct(Aircraft $aircraft)
|
|
{
|
|
$this->aircraft = $aircraft;
|
|
parent::__construct(
|
|
400,
|
|
static::MESSAGE
|
|
);
|
|
}
|
|
|
|
public function getErrorType(): string
|
|
{
|
|
return 'aircraft-not-available';
|
|
}
|
|
|
|
public function getErrorDetails(): string
|
|
{
|
|
return $this->getMessage();
|
|
}
|
|
|
|
public function getErrorMetadata(): array
|
|
{
|
|
return [
|
|
'aircraft_id' => $this->aircraft->id,
|
|
];
|
|
}
|
|
}
|