diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index e10371f87b6..77356ba2a87 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -267,8 +267,8 @@ class Categories extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!$this->category->delete(DolibarrApiAccess::$user)) { - throw new RestException(401, 'error when delete category'); + if ($this->category->delete(DolibarrApiAccess::$user) <= 0) { + throw new RestException(500, 'Error when delete category : ' . $this->category->error); } return array( diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index afd6c5807a5..d8839c9a122 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -348,7 +348,7 @@ class Contacts extends DolibarrApi * Delete contact * * @param int $id Contact ID - * @return integer + * @return array[] */ public function delete($id) { @@ -364,7 +364,17 @@ class Contacts extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->contact->oldcopy = clone $this->contact; - return $this->contact->delete(); + + if ($this->contact->delete() <= 0) { + throw new RestException(500, 'Error when delete contact ' . $this->contact->error); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact deleted' + ) + ); } /**