Skip to main content
deleted 2 characters in body; edited title
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

throwing Throwing an exception within a try catch/catch block in phpPHP

isIs there a cleaner way to do this?

    try {
        $ffprobe      = FFProbe::create();
        $streams      = $ffprobe->streams($infile);
        $videoStreams = $streams->videos();
        $audioStreams = $streams->audios();

        if (!$videoStreams) {
            throw new Exception("Could not find a video stream for file: " . $infile . PHP_EOL);
        }

    } catch (RuntimeException $e) {
        throw $e;
    }

throwing an exception within a try catch block in php

is there a cleaner way to do this?

    try {
        $ffprobe      = FFProbe::create();
        $streams      = $ffprobe->streams($infile);
        $videoStreams = $streams->videos();
        $audioStreams = $streams->audios();

        if (!$videoStreams) {
            throw new Exception("Could not find a video stream for file: " . $infile . PHP_EOL);
        }

    } catch (RuntimeException $e) {
        throw $e;
    }

Throwing an exception within a try/catch block in PHP

Is there a cleaner way to do this?

    try {
        $ffprobe      = FFProbe::create();
        $streams      = $ffprobe->streams($infile);
        $videoStreams = $streams->videos();
        $audioStreams = $streams->audios();

        if (!$videoStreams) {
            throw new Exception("Could not find a video stream for file: " . $infile . PHP_EOL);
        }

    } catch (RuntimeException $e) {
        throw $e;
    }
Source Link

throwing an exception within a try catch block in php

is there a cleaner way to do this?

    try {
        $ffprobe      = FFProbe::create();
        $streams      = $ffprobe->streams($infile);
        $videoStreams = $streams->videos();
        $audioStreams = $streams->audios();

        if (!$videoStreams) {
            throw new Exception("Could not find a video stream for file: " . $infile . PHP_EOL);
        }

    } catch (RuntimeException $e) {
        throw $e;
    }