Fix error process

This commit is contained in:
Cédric 2019-11-14 22:16:08 +01:00 committed by GitHub
parent 88692fe95d
commit 100827ae0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -295,8 +295,11 @@ class Categories extends DolibarrApi
$categories = $this->category->getListForItem($id, $type, $sortfield, $sortorder, $limit, $page);
if( ! count($categories)) {
throw new RestException(404, 'No category found for this object');
if( ! is_array($categories)) {
if ($categories == 0) {
throw new RestException(404, 'No category found for this object');
}
throw new RestException(500, 'Error when fetching object categories', array_merge(array($this->category->error), $this->category->errors));
}
return $categories;
}