-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObserver.php
30 lines (26 loc) · 997 Bytes
/
Observer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
namespace Code16\OzuClient\Deploy\Crawler;
use Log;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;
use Spatie\Export\Crawler\Observer as BaseObserver;
class Observer extends BaseObserver
{
public function crawled(UriInterface $url, ResponseInterface $response, ?UriInterface $foundOnUrl = null, ?string $linkText = null): void
{
try {
parent::crawled($url, $response, $foundOnUrl, $linkText);
} catch (\RuntimeException $e) {
if (preg_match('/returned status code \[4\d\d]/', $e->getMessage())) {
Log::warning("Crawled URL {$url} found on {$foundOnUrl} returned status code 4xx", [
'url' => (string) $url,
'status_code' => $response->getStatusCode(),
'found_on_url' => (string) $foundOnUrl,
'link_text' => $linkText,
]);
return;
}
throw $e;
}
}
}