Skip to content

Commit ffbf750

Browse files
committed
Improves the exception message when a request is not found in a cassette.
See php-vcr#94 for further information.
1 parent afa5373 commit ffbf750

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/VCR/Videorecorder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,9 @@ public function handleRequest(Request $request)
225225

226226
if ($this->config->getMode() == 'none' || $this->config->getMode() == 'once' && $this->cassette->isNew() === false) {
227227
throw new \LogicException(
228-
"Invalid http request. The cassette inserted did not have the necessary response. "
229-
. "If you want to send a request anyway, make sure your mode is set to new_episodes.");
228+
"The request does not match a previously recorded request and the 'mode' is set to '{$this->config->getMode()}'. "
229+
. "If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'. "
230+
. "Please see http://php-vcr.github.io/documentation/configuration/#record-modes.");
230231
}
231232

232233
$this->disableLibraryHooks();

tests/VCR/VideorecorderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ public function testHandleRequestThrowsExceptionWhenModeIsNone()
6262
{
6363
$this->setExpectedException(
6464
'LogicException',
65-
"Invalid http request. The cassette inserted did not have the necessary response. "
66-
. "If you want to send a request anyway, make sure your mode is set to new_episodes.");
65+
"The request does not match a previously recorded request and the 'mode' is set to 'none'. "
66+
. "If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'.");
6767

6868
$request = new Request('GET', 'http://example.com', array('User-Agent' => 'Unit-Test'));
6969
$response = new Response(200, array(), 'example response');
@@ -109,8 +109,8 @@ public function testHandleRequestThrowsExceptionWhenModeIsOnceAndCassetteIsOld()
109109
{
110110
$this->setExpectedException(
111111
'LogicException',
112-
"Invalid http request. The cassette inserted did not have the necessary response. "
113-
. "If you want to send a request anyway, make sure your mode is set to new_episodes.");
112+
"The request does not match a previously recorded request and the 'mode' is set to 'once'. "
113+
. "If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'.");
114114

115115
$request = new Request('GET', 'http://example.com', array('User-Agent' => 'Unit-Test'));
116116
$response = new Response(200, array(), 'example response');

0 commit comments

Comments
 (0)