Fix consistency in sessions not found exceptions

This commit is contained in:
Jérémy Derussé 2021-02-06 11:31:59 +01:00
parent a12db94a06
commit 7fcb76d367
No known key found for this signature in database
GPG Key ID: 2083FA5758C473D2
2 changed files with 3 additions and 1 deletions

View File

@ -4,6 +4,7 @@ CHANGELOG
5.3
---
* Calling `Request::getSession()` when there is no available session throws a `SessionNotFoundException`
* Add the `RequestStack::getSession` method
* Deprecate the `NamespacedAttributeBag` class
* added `ResponseFormatSame` PHPUnit constraint

View File

@ -13,6 +13,7 @@ namespace Symfony\Component\HttpFoundation;
use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
use Symfony\Component\HttpFoundation\Exception\JsonException;
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
@ -735,7 +736,7 @@ class Request
}
if (null === $session) {
throw new \BadMethodCallException('Session has not been set.');
throw new SessionNotFoundException('Session has not been set.');
}
return $session;