better propagation of HTTP response

This commit is contained in:
Evan Prodromou 2012-03-19 01:59:26 -04:00
parent c4cc7dbe64
commit 6a49e26321
1 changed files with 2 additions and 10 deletions

View File

@ -78,10 +78,6 @@ class SpamFilter extends OAuthClient {
$response = $this->postJSON($this->server . "/is-this-spam", $activity->asArray()); $response = $this->postJSON($this->server . "/is-this-spam", $activity->asArray());
if (!$response->isOK()) {
throw new Exception("Error " . $response->getStatus() . " checking spam score: " . $response->getBody());
}
$result = json_decode($response->getBody()); $result = json_decode($response->getBody());
return $result; return $result;
@ -109,10 +105,6 @@ class SpamFilter extends OAuthClient {
$response = $this->postJSON($this->server . $endpoint, $activity->asArray()); $response = $this->postJSON($this->server . $endpoint, $activity->asArray());
if (!$response->isOK()) {
throw new Exception("Error " . $response->getStatus() . " checking spam score: " . $response->getBody());
}
// We don't do much with the results // We don't do much with the results
return true; return true;
} }
@ -168,10 +160,10 @@ class SpamFilter extends OAuthClient {
try { try {
$response = $hclient->send(); $response = $hclient->send();
$code = $response->getStatus(); $code = $response->getStatus();
if ($code < 200 || $code >= 400) { if (!$response->isOK()) {
throw new OAuthClientException($response->getBody(), $code); throw new OAuthClientException($response->getBody(), $code);
} }
return $response->getBody(); return $response;
} catch (Exception $e) { } catch (Exception $e) {
throw new OAuthClientException($e->getMessage(), $e->getCode()); throw new OAuthClientException($e->getMessage(), $e->getCode());
} }