Implement robust error handling and configuration for Logistics API interactions

- Introduced `LogisticsApiException` to handle connection and request errors with user-friendly messages in French.
- Updated `LogisticsService` to include configurable timeout, connection timeout, retry attempts, and sleep duration for retries.
- Enhanced error handling in Filament pages to catch `LogisticsApiException` and provide clear feedback to users.
- Updated `.env` and `config/logistics.php` to support new configuration options.
- Added logging for failed API requests in `api_request_logs`.
- Created comprehensive API documentation for Logistics endpoints.
This commit is contained in:
2026-02-20 10:06:04 +01:00
parent 07a3b3a874
commit 4aef33f270
18 changed files with 820 additions and 64 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Exceptions;
use RuntimeException;
class LogisticsApiException extends RuntimeException
{
public function __construct(
string $message,
public readonly string $endpoint = '',
public readonly array $params = [],
int $code = 0,
?\Throwable $previous = null,
) {
parent::__construct($message, $code, $previous);
}
public static function connectionTimeout(string $endpoint, array $params, \Throwable $previous): self
{
return new self(
message: "L'API Logistics est injoignable. Verifiez que le serveur est accessible et que votre connexion reseau fonctionne.",
endpoint: $endpoint,
params: $params,
previous: $previous,
);
}
public static function requestFailed(string $endpoint, array $params, \Throwable $previous): self
{
return new self(
message: "La requete vers l'API Logistics a echoue : {$previous->getMessage()}",
endpoint: $endpoint,
params: $params,
previous: $previous,
);
}
}