Fix exceptions handlers

This commit is contained in:
Romain Neutron 2012-04-13 15:21:52 +02:00
commit 32de2b39da
5 changed files with 58 additions and 10 deletions

View file

@ -0,0 +1,17 @@
<?php
/*
* This file is part of PHP-FFmpeg.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FFMpeg\Exception;
class InvalidFileArgumentException extends \InvalidArgumentException
{
}

View file

@ -0,0 +1,17 @@
<?php
/*
* This file is part of PHP-FFmpeg.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FFMpeg\Exception;
class LogicException extends \LogicException
{
}

View file

@ -0,0 +1,17 @@
<?php
/*
* This file is part of PHP-FFmpeg.
*
* (c) Alchemy <info@alchemy.fr>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace FFMpeg\Exception;
class RuntimeException extends \RuntimeException
{
}

View file

@ -51,12 +51,13 @@ class FFMpeg extends Binary
* @param int $height The height of the image
* @return boolean True if success
* @throws Exception\RuntimeException
* @throws Exception\LogicException
*/
public function extractImage($time, $output, $width, $height)
{
if ( ! $this->pathfile)
{
throw new Exception\RuntimeException('No file open');
throw new Exception\LogicException('No file open');
}
$cmd = $this->binary
@ -99,12 +100,13 @@ class FFMpeg extends Binary
* @param int $threads The number of threads to use
* @return boolean True if success
* @throws Exception\RuntimeException
* @throws Exception\LogicException
*/
public function encode(Format\AudioFormat $format, $outputPathfile, $threads = 1)
{
if ( ! $this->pathfile)
{
throw new Exception\RuntimeException('No file open');
throw new Exception\LogicException('No file open');
}
$threads = max(min($threads, 64), 1);

View file

@ -27,6 +27,7 @@ class FFProbe extends Binary
* @param string $pathfile
* @return string
* @throws Exception\InvalidFileArgumentException
* @throws Exception\RuntimeException
*/
public function probeFormat($pathfile)
{
@ -46,6 +47,7 @@ class FFProbe extends Binary
* @param string $pathfile
* @return string
* @throws Exception\InvalidFileArgumentException
* @throws Exception\RuntimeException
*/
public function probeStreams($pathfile)
{
@ -56,15 +58,8 @@ class FFProbe extends Binary
$cmd = $this->binary . ' ' . $pathfile . ' -show_streams';
try
{
return $this->executeProbe($cmd);
}
catch (Exception\RuntimeException $e)
{
}
}
/**
*