Skip to content

Commit da5d6c4

Browse files
committed
Fix consistency in sessions not found exceptions
1 parent 6ff56c8 commit da5d6c4

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
5.3
55
---
66

7+
* Calling `Request::getSession()` when there is no available session throws a `SessionNotFoundException`
78
* Add the `RequestStack::getSession` method
89
* Deprecate the `NamespacedAttributeBag` class
910
* added `ResponseFormatSame` PHPUnit constraint

Request.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
1515
use Symfony\Component\HttpFoundation\Exception\JsonException;
16+
use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException;
1617
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
1718
use Symfony\Component\HttpFoundation\Session\SessionInterface;
1819

@@ -735,7 +736,7 @@ public function getSession()
735736
}
736737

737738
if (null === $session) {
738-
throw new \BadMethodCallException('Session has not been set.');
739+
throw new SessionNotFoundException('Session has not been set.');
739740
}
740741

741742
return $session;

0 commit comments

Comments
 (0)