ekart/backend/app/Exceptions/StaleCartException.php
2026-03-18 18:59:45 +05:30

31 lines
662 B
PHP

<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Http\JsonResponse;
class StaleCartException extends Exception
{
public function __construct(
public readonly int|string $userId,
public readonly int|string $cartId,
public $message = 'Attempt to create a order with a stale cart',
) {
parent::__construct($message);
}
public function context(): array
{
return [
'user_id' => $this->userId,
'cart_id' => $this->cartId,
];
}
public function render(): JsonResponse
{
return response()->json(['message' => 'Cart is stale'], 409);
}
}