Skip to content

Commit

Permalink
catch mapping exception on getdescription
Browse files Browse the repository at this point in the history
  • Loading branch information
priyadi committed Sep 26, 2023
1 parent 22fdabb commit 4d6d061
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 7 additions & 3 deletions packages/file/src/Type/MimeMapFileTypeAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
}
}
}

0 comments on commit 4d6d061

Please sign in to comment.