techjoomla / com_api

API framework for Joomla
http://docs.techjoomla.com/joomla-rest-api/com-api-introduction
GNU General Public License v3.0
123 stars 97 forks source link

Wrong parameters for APINotFoundException #57

Closed mrsadeqij closed 7 years ago

mrsadeqij commented 7 years ago

Hi, I want to use com_api to write an api for the Hikashop component. But when I use ApiError::raiseError("ERR005", "Record not found", 'APINotFoundException');
I get this error.

Wrong parameters for APINotFoundException([string $message [, long $code [, Throwable $previous = NULL]]])

coolbung commented 7 years ago

All the API Exceptions extend PHP's exceptions. Since PHP enforces numeric-only exception codes you can only use a numeric code. You can use the message to send the details.

The below code will work ApiError::raiseError(5, "Record not found", 'APINotFoundException');

coolbung commented 7 years ago

The documentation was incorrect and did use non-numeric code. I've updated the docs http://techjoomla.github.io/com_api/#error-handling