0

I have a simple php library https://github.com/MonsterGfx/PHP-MPD-Client

It's work fine with my symfony2, but until mpd server is offline. I want to check mpd status -

static function checkSource(\MDS\SiteBundle\Entity\Source $source)
{
    try {
        MPD::connect($source->getMpdpassword(), $source->getMpdhost(), $source->getMpdport());
    } catch (MPDConnectionFailedException $e) {
        return false;
    }
    $ping = MPD::send("ping");
    if ($ping['status'] == 'OK') {
        return true;
    } else {
        return false;
    }
}

Problem is when server is offline, I get throw

Warning: fsockopen(): unable to connect to planeset.ru:6600 (Connection refused) 500 Internal Server Error - ContextErrorException

But I have to catch error. I see the code in the library

if(!static::$fp)
{
// no connection
 throw new MPDConnectionFailedException("$errstr ($errno)");
}

Why I can't catch error and have a 500 error ? What I do wrong way ?

zalex
  • 729
  • 6
  • 14
  • The message you're gettting is not an exception, but an E_WARNING error. Those are different concepts in PHP (at least in PHP 5). – Wouter J Apr 26 '15 at 13:44
  • Yes, I pay attention on this,But I have a 500 error and can't understand how I can correct execute my requert. – zalex Apr 26 '15 at 13:47

0 Answers0