PHP Trait App\Traits\RestExceptionHandlerTrait

Mostra file Open project: ngmy/webloyer

Protected Methods

Method Description
badRequest ( string $message = 'Bad request', integer $statusCode = 400 ) : Illuminate\Http\JsonResponse Return JSON response for bad request.
getJsonResponseForException ( Illuminate\Http\Request $request, Exception $e ) : Illuminate\Http\JsonResponse Create a new JSON response based on exception type.
internalError ( string $message = 'Internal error', integer $statusCode = 500 ) : Illuminate\Http\JsonResponse Return JSON response for internal error.
jsonResponse ( array $payload = null, integer $statusCode = 404 ) : Illuminate\Http\JsonResponse Return JSON response.
notFound ( string $message = 'Not found', integer $statusCode = 404 ) : Illuminate\Http\JsonResponse Return JSON response for not found.
unauthorized ( string $message = 'Unauthorized', integer $statusCode = 401 ) : Illuminate\Http\JsonResponse Return JSON response for unauthorized.

Method Details

badRequest() protected method

Return JSON response for bad request.
protected badRequest ( string $message = 'Bad request', integer $statusCode = 400 ) : Illuminate\Http\JsonResponse
$message string
$statusCode integer
return Illuminate\Http\JsonResponse

getJsonResponseForException() protected method

Create a new JSON response based on exception type.
protected getJsonResponseForException ( Illuminate\Http\Request $request, Exception $e ) : Illuminate\Http\JsonResponse
$request Illuminate\Http\Request
$e Exception
return Illuminate\Http\JsonResponse

internalError() protected method

Return JSON response for internal error.
protected internalError ( string $message = 'Internal error', integer $statusCode = 500 ) : Illuminate\Http\JsonResponse
$message string
$statusCode integer
return Illuminate\Http\JsonResponse

jsonResponse() protected method

Return JSON response.
protected jsonResponse ( array $payload = null, integer $statusCode = 404 ) : Illuminate\Http\JsonResponse
$payload array
$statusCode integer
return Illuminate\Http\JsonResponse

notFound() protected method

Return JSON response for not found.
protected notFound ( string $message = 'Not found', integer $statusCode = 404 ) : Illuminate\Http\JsonResponse
$message string
$statusCode integer
return Illuminate\Http\JsonResponse

unauthorized() protected method

Return JSON response for unauthorized.
protected unauthorized ( string $message = 'Unauthorized', integer $statusCode = 401 ) : Illuminate\Http\JsonResponse
$message string
$statusCode integer
return Illuminate\Http\JsonResponse