'Une erreur serveur est survenue.']; if (Security::debugEnabled()) { $payload['details'] = $exception->getMessage(); } Security::reportThrowable($exception, 'Erreur API.'); self::send(500, $payload); }); } public static function send(int $status, array $payload): void { if (!headers_sent()) { header('Content-Type: application/json; charset=utf-8'); header('X-Content-Type-Options: nosniff'); header('Cache-Control: no-store'); } http_response_code($status); echo json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_SUBSTITUTE); exit; } }