PHP HTTP Exceptions
composer require controlabs/http-exceptions
use Controlabs\Http\Exception\BadRequest;
Throws an Bad Request exception:
throw new BadRequest();
Throws an exception with a custom message:
throw new BadRequest("I'm gonna make him an offer he can't refuse.");
Response (it can return in JSON or ARRAY format):
try {
} catch (BadRequest $e) {
$e->response()->toArray();
// or
$e->response()->toJson();
}
This software is open source, licensed under the The MIT License (MIT). See LICENSE for details.