getMessage(), $exception->getFile(), $exception->getLine() )); $payload = ['error' => 'Une erreur serveur est survenue.']; if ((getenv('PTA_DEBUG') ?: '1') !== '0') { $payload['details'] = $exception->getMessage(); } self::send(500, $payload); }); } public static function send(int $status, array $payload): void { if (!headers_sent()) { header('Content-Type: application/json; charset=utf-8'); } http_response_code($status); echo json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_SUBSTITUTE); exit; } }