チェックイン時のメタデータ取得に失敗した際、ログだけ残して終了する
This commit is contained in:
parent
168ef1c5f6
commit
ca02f21812
@ -6,8 +6,10 @@ use App\Events\LinkDiscovered;
|
|||||||
use App\Metadata;
|
use App\Metadata;
|
||||||
use App\MetadataResolver\MetadataResolver;
|
use App\MetadataResolver\MetadataResolver;
|
||||||
use App\Utilities\Formatter;
|
use App\Utilities\Formatter;
|
||||||
|
use GuzzleHttp\Exception\TransferException;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class LinkCollector
|
class LinkCollector
|
||||||
{
|
{
|
||||||
@ -42,13 +44,19 @@ class LinkCollector
|
|||||||
// TODO: ある程度古かったら再取得とかありだと思う
|
// TODO: ある程度古かったら再取得とかありだと思う
|
||||||
$metadata = Metadata::find($url);
|
$metadata = Metadata::find($url);
|
||||||
if ($metadata == null) {
|
if ($metadata == null) {
|
||||||
$resolved = $this->metadataResolver->resolve($url);
|
try {
|
||||||
Metadata::create([
|
$resolved = $this->metadataResolver->resolve($url);
|
||||||
'url' => $url,
|
Metadata::create([
|
||||||
'title' => $resolved->title,
|
'url' => $url,
|
||||||
'description' => $resolved->description,
|
'title' => $resolved->title,
|
||||||
'image' => $resolved->image
|
'description' => $resolved->description,
|
||||||
]);
|
'image' => $resolved->image
|
||||||
|
]);
|
||||||
|
} catch (TransferException $e) {
|
||||||
|
// 何らかの通信エラーによってメタデータの取得に失敗した時、とりあえずエラーログにURLを残す
|
||||||
|
Log::error(self::class . ': メタデータの取得に失敗 URL=' . $url);
|
||||||
|
report($e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user