Fix exceptions handlers
This commit is contained in:
parent
4582e152df
commit
32de2b39da
5 changed files with 58 additions and 10 deletions
17
src/FFMpeg/Exception/InvalidFileArgumentException.php
Normal file
17
src/FFMpeg/Exception/InvalidFileArgumentException.php
Normal 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
|
||||
{
|
||||
|
||||
}
|
||||
17
src/FFMpeg/Exception/LogicException.php
Normal file
17
src/FFMpeg/Exception/LogicException.php
Normal 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
|
||||
{
|
||||
|
||||
}
|
||||
17
src/FFMpeg/Exception/RuntimeException.php
Normal file
17
src/FFMpeg/Exception/RuntimeException.php
Normal 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
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,14 +58,7 @@ class FFProbe extends Binary
|
|||
|
||||
$cmd = $this->binary . ' ' . $pathfile . ' -show_streams';
|
||||
|
||||
try
|
||||
{
|
||||
return $this->executeProbe($cmd);
|
||||
}
|
||||
catch (Exception\RuntimeException $e)
|
||||
{
|
||||
|
||||
}
|
||||
return $this->executeProbe($cmd);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue