diff --git a/classes/Downloader.php b/classes/Downloader.php index e9555f2..c74bf94 100644 --- a/classes/Downloader.php +++ b/classes/Downloader.php @@ -235,7 +235,7 @@ class Downloader } elseif (substr($errorOutput, 0, 21) == 'ERROR: Wrong password') { throw new WrongPasswordException($errorOutput, $exitCode); } else { - throw new YoutubedlException($errorOutput, $exitCode); + throw new YoutubedlException($process); } } else { return trim($process->getOutput()); diff --git a/classes/exceptions/YoutubedlException.php b/classes/exceptions/YoutubedlException.php index 2988869..56de344 100644 --- a/classes/exceptions/YoutubedlException.php +++ b/classes/exceptions/YoutubedlException.php @@ -2,9 +2,23 @@ namespace Alltube\Library\Exception; +use Symfony\Component\Process\Process; + /** * Generic youtube-dl error. */ class YoutubedlException extends AlltubeLibraryException { + /** + * YoutubedlException constructor. + * + * @param Process $process Process that caused the exception + */ + public function __construct(Process $process) + { + parent::__construct( + $process->getCommandLine() . ' failed with this error:' . PHP_EOL . trim($process->getErrorOutput()), + intval($process->getExitCode()) + ); + } }