saccharine
saccharine

Reputation: 904

Symfony2 Exceptions Break App

I'm using the Facebook PHP SDK with Symfony. Whenever I use the SDK I have it in a try and catch. However, Symfony breaks the app and throws up an error page. Normally this is really useful for debugging, but for the FB Exceptions I would much rather it let me handle it within the app itself.

Is there anyway for me to tell Symfony to just handle it like plain php?

Eg

$this->fb = new \Facebook($this->config);
$url = (string)
try {
    $result = $this->fb->api($url, 'POST');
    return $result;
}
catch (FacebookApiException $e) {
    return;
}

I get a page from Symfony describing the exception, when I want to handle it myself.

Upvotes: 0

Views: 199

Answers (1)

Samy Dindane
Samy Dindane

Reputation: 18706

The thrown exception isn't caught because it is different than FacebookApiException.
Since you're in a controller, you need to add a backslash to the exception's name: \FacebookApiException, so PHP would look for it in the global namespace instead of the controller's one.

Upvotes: 1

Related Questions