Skip to content

Commit

Permalink
Throw exeption when the server rejects the query.
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasdelellis committed Nov 23, 2020
1 parent ddc5a21 commit 1bffc39
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/Model/ExternalModel/ExternalModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,17 @@ public function open() {
throw new \Exception('Cannot connect to external model: ' . curl_error($ch));
}

curl_close($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode !== 200) {
throw new \Exception('Can\'t connect with external model. HTTP status code: ' . $httpCode);
}

$jsonResponse = json_decode($response, true);

$this->maximumImageArea = intval($jsonResponse['maximum_area']);
$this->preferredMimetype = $jsonResponse['preferred_mimetype'];

curl_close($ch);
}

public function detectFaces(string $imagePath, bool $compute = true): array {
Expand Down

0 comments on commit 1bffc39

Please sign in to comment.