3.2 - Handling errors
Learning error handling with the library is essential to begin. If you implement this verification directly, you immediately detect where the error comes from along with other information.
Error handling with the PHP library from the web service is done with the help of exceptions.
The principle
The treatments related to the PrestaShop web service must be within a try block which itself must be followed by a catch block to retrieve the errors and, if possible, to catch them.
Illustration:
Example
That means each creation or use of the library must be located within a "try" block. The "catch" block can then handle the error if it occurs during the execution of the try block. Now we'll see how to list all customers via the web service, and then we will see the four CRUD methods.
Last updated