Exception handling added

This commit is contained in:
Michael 2023-12-05 22:33:45 +00:00
parent 0df88fd5a0
commit 914d4506e2
2 changed files with 6 additions and 2 deletions

View File

@ -49,7 +49,7 @@ class PostMedia extends BaseFactory implements ICanCreateFromTableRow
{
return new Entity\PostMedia(
$row['uri-id'],
UtilNetwork::createUriFromString($row['url']) ?: '',
UtilNetwork::createUriFromString($row['url']),
$row['type'],
$this->mimeTypeFactory->createFromContentType($row['mimetype']),
$row['media-uri-id'],

View File

@ -45,7 +45,11 @@ class PostMedia extends BaseRepository
$Entities = new Collection\PostMedias();
foreach ($rows as $fields) {
try {
$Entities[] = $this->factory->createFromTableRow($fields);
} catch (\Exception $e) {
$this->logger->warning('Invalid media row', ['code' => $e->getCode(), 'message' => $e->getMessage(), 'fields' => $fields]);
}
}
return $Entities;