🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Monolog\Handler\FingersCrossed\ActivationStrategyInterface;
use Monolog\LogRecord;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;

/**
* Activation strategy that ignores certain HTTP codes.
Expand Down Expand Up @@ -49,7 +49,7 @@ public function isHandlerActivated(array|LogRecord $record): bool
if (
$isActivated
&& isset($record['context']['exception'])
&& $record['context']['exception'] instanceof HttpException
&& $record['context']['exception'] instanceof HttpExceptionInterface
&& ($request = $this->requestStack->getMainRequest())
) {
foreach ($this->exclusions as $exclusion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Symfony\Bridge\Monolog\Tests\RecordFactory;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;

class HttpCodeActivationStrategyTest extends TestCase
{
Expand Down Expand Up @@ -74,6 +74,23 @@ public static function isActivatedProvider(): array

private static function getContextException(int $code): array
{
return ['exception' => new HttpException($code)];
return ['exception' => new class($code) extends \RuntimeException implements HttpExceptionInterface {
private int $statusCode;

public function __construct(int $statusCode)
{
$this->statusCode = $statusCode;
}

public function getStatusCode(): int
{
return $this->statusCode;
}

public function getHeaders(): array
{
return [];
}
}];
}
}