diff --git a/CHANGELOG.md b/CHANGELOG.md index 23a55da..6b62f99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 0.1.2 + +* FileType: Catch `MappingException` on `getDescription()`. + ## 0.1.1 * Use `sys_get_temp_dir()` and `tempnam()` to get a temporary file path if the diff --git a/packages/file/src/Type/MimeMapFileTypeAdapter.php b/packages/file/src/Type/MimeMapFileTypeAdapter.php index 441ac6b..4c5daa9 100644 --- a/packages/file/src/Type/MimeMapFileTypeAdapter.php +++ b/packages/file/src/Type/MimeMapFileTypeAdapter.php @@ -80,8 +80,12 @@ public function getExtension(): ?string public function getDescription(): string|(\Stringable&TranslatableInterface) { - return new TranslatableTypeDescription( - $this->getParsed()->getDescription() - ); + try { + return $this->getParsed()->getDescription(); + } catch (MappingException) { + return new TranslatableTypeDescription( + 'Unknown file type' + ); + } } }