Is this the right way to handle Exceptions in PHP? I'm using the function countLikes() to fetch URLs' Likes count from the Facebook API.

// Link.php

class Link
{

private $url;

public function __construct($url){
    $this-&gt;url = new Url($url);
}

public function getUrl(){
    return $this-&gt;url();
}

public function countLikes()
{
    global $config;

    $call = $config["facebook.api"]["baseurl"] .
            "/" .
            $config["facebook.api"]["version"] .
            "/?" .
            "id=" . $this-&gt;url-&gt;getEncodedUrl() .
            "&amp;access_token=" . $config["facebook.api"]["key"];

    try {
        $response = Utils::curl($call);
    } catch (\Exception $e) {
        throw new LinkException("Unable to cURL Facebook API.", 0, $e);
    }

    if (is_array($response)) {
        if (array_key_exists("error", $response)) {
            throw new LinkException(
            "Facebook Graph API v2.2 error : "
            . $response["error"]["message"], $response["error"]["code"]
            );
        } elseif (isset($response["share"])) {
            $count = $response["share"]["share_count"];
        } else {
            $count = 0;
        }

        return $count;
    } else {
        throw new LinkException("Graph API Response is not an array");
    }
}
}


And this is how it's used : 

$link = new Link("http://www.facebook.com");

try{
    $likes = $link-&gt;countLikes();
    echo "Link $link-&gt;getUrl()-&gt;getFullUrl() has $likes likes for the moment. &lt;br&gt;";
} catch(LinkException $e){
    do{
        $logger-&gt;add($e-&gt;getMessage());
    }while ($e = $e-&gt;getPrevious());
}


While this is working as it's supposed to do, I'm not happy with the way exceptions are treated and I'm not even sure this is the right way to do it. Is there a better way to manage exceptions and handle them?
You are using Exceptions correctly, however its possible to catch more than one type of exception with the same try block. Instead of specifically catching the LinkException in your logging routine, you should probably just catch any Exception, but prefix the error string with the Exception's class.

I also recommend putting the declaration of the $link object inside the try block in case the Url class throws an exception from inside the Link class's constructor.

try {
    // execute code
    $foo = new Foo();
} catch ( \Exception $e ) {
    // log exceptions
    $logger-&gt;add( get_class( $e ) . ': ' . $e-&gt;getMessage() );
}


Push your logging as high up in your application as possible so you are collecting all exceptions, not just your custom ones.