public function Lockr::handleError in Lockr 7.2
Parses an error response and throws the correct exception.
1 call to Lockr::handleError()
- Lockr::request in vendor/
lockr/ lockr-client/ src/ Lockr.php
File
- vendor/
lockr/ lockr-client/ src/ Lockr.php, line 185
Class
- Lockr
- Primary interface for Lockr API calls.
Namespace
LockrCode
public function handleError($code, $body) {
$title = isset($body['title']) ? $body['title'] : '';
$description = isset($body['description']) ? $body['description'] : '';
$params = array(
'title' => $title,
'description' => $description,
'message' => "[{$title}]: {$description}",
'code' => $code,
);
if ($code >= 500) {
throw new LockrServerException($params);
}
throw new LockrClientException($params);
}