Skip to content

Commit

Permalink
Do not throw exceptions anymore when mime-type detection fails
Browse files Browse the repository at this point in the history
Create a GenericMedia instead of throwing an exception. Detection of the
expected type can be delegated to the client.
  • Loading branch information
Vincent Lepot committed May 6, 2015
1 parent 2723a74 commit 9b4595d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Media/Factory/MediaFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use CanalTP\MediaManager\Media\PictureMedia;
use CanalTP\MediaManager\Media\PdfMedia;
use CanalTP\MediaManager\Media\Factory\MediaFactoryInterface;
use CanalTP\MediaManager\Media\GenericMedia;

class MediaFactory implements MediaFactoryInterface
{
Expand Down Expand Up @@ -38,7 +39,7 @@ private function determine()
$this->type = MediaType::PDF;
break;
default:
throw new \Exception('MediaManager can be save this type: ' . $this->mime);
$this->type = MediaType::UNKNOWN;
}
}

Expand All @@ -56,6 +57,9 @@ private function product()
case MediaType::PDF:
$media = new PdfMedia();
break;
case MediaType::UNKNOWN:
$media = new GenericMedia();
break;
}

return ($media);
Expand Down

0 comments on commit 9b4595d

Please sign in to comment.