Skip to content

Commit 15c0084

Browse files
Fix: Handle exceptions in Retrieve and update test usage
Co-authored-by: zembrowski <zembrowski@rechtlogisch.de>
1 parent 0e25049 commit 15c0084

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Retrieve.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ public function page(int $no = 1): void
8888
$this->retrieved[$tseId] = $rowData;
8989
});
9090
} catch (Throwable $e) {
91-
$html = $this->browser->getResponse()->getContent();
91+
$html = null;
92+
try {
93+
$html = $this->browser->getResponse()->getContent();
94+
} catch (Throwable) {
95+
// No response available (request failed before completion)
96+
// This is expected when the initial request() call fails
97+
}
9298
throw (new RetrieveException($e->getMessage(), $e->getCode(), $e->getPrevious()))
9399
->addContext($url, $html);
94100
}

tests/ExternalTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
use Rechtlogisch\TseId\Retrieve;
44

5-
$retrieve = (function () {
5+
$retrieve = function () {
66
return new Retrieve;
7-
})();
7+
};
88

99
it('retrieve data from BSI website', function () use (&$retrieve) {
10-
$list = $retrieve->list();
10+
$list = $retrieve()->list();
1111
expect($list)
1212
->toBeArray()
1313
->not->toBeEmpty()

0 commit comments

Comments
 (0)