123456789101112131415161718192021222324252627 |
- <?php
- namespace App\Exceptions;
- use Exception;
- use Illuminate\Http\Exceptions\HttpResponseException;
- class ApiException extends HttpResponseException
- {
- public function __construct($code = 422, $message="Validation error", $errors=[])
- {
- $data=[
- 'error'=>[
- "code"=>$code,
- "message"=>$message
- ]
- ];
- if ($errors) {
- $data["error"]["errors"] = $errors;
- }
- parent::__construct(response()->json($data, $code));
- }
- }
|