Home
+91 99674 50288
info@appmonks.net
×

Laravel API Exceptions

What is Laravel API Errors:

The API spec defines error objects that are returned in the top-level errors member of the response body. This package automatically handles converting common exceptions to error objects, for example HTTP exceptions and validation exceptions.

Creating Error Objects:

Error objects can be constructed from array key and value pairs using the static fromArray method on the package's error class. All the keys are described in the specification's error objects chapter are supported.

Every request to the API returns status code, for successful requests it’s usually 200, or 2xx with XX as other number.

Status Code Meaning

404 Not Found (page doesn’t exist)

401 Not authorized (not logged in)

403 Logged in but access to requested area is a forbidden

400 Bad request (something wrong URL or parameters)

422 Unprocessable Entity (validation failed)

500 General server error

Exception Handling in Laravel

Laravel is two Kernels one for handle HTTP requests and the other for handling console commands, each Kernel has a handle() methode that receives the input, either an HTTP Request or a Console Input handles it, and returns a response. The entire handling process is wrapped inside a try and catch.

Mail
casino