When the Pusher Push Notifications API returns an error response that is either not valid JSON or doesn't contain the expected error and description properties, the SDK throws a generic exception with the message "An unexpected server error has occurred". This makes debugging difficult as it hides the actual HTTP status code and response details.
catch (\GuzzleHttp\Exception\BadResponseException $e) {
$response = $e->GetResponse();
$parsedResponse = json_decode($response->GetBody());
$badJSON = $parsedResponse === null;
if (
$badJSON ||
!property_exists($parsedResponse, 'error') ||
!property_exists($parsedResponse, 'description')
) {
throw new \Exception("An unexpected server error has occurred");
}
}
When the Pusher Push Notifications API returns an error response that is either not valid JSON or doesn't contain the expected error and description properties, the SDK throws a generic exception with the message "An unexpected server error has occurred". This makes debugging difficult as it hides the actual HTTP status code and response details.