1. Exception 클래스 생성
<?php
namespace App\Exceptions;
use Exception;
class DevelopException extends exception {
/**
* Report the exception.
*
* @return void
*/
public function report()
{
//
}
/**
* Render the exception into an HTTP response.
*
* @param \Illuminate\Http\Request
* @return \Illuminate\Http\Response
*/
public function render($request)
{
return response('Error');
}
}
2. Custom Exception 사용
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Exceptions\DevelopException;
class DbTestController extends Controller
{
/**
* Show a list of all of the application's users.
*
* @return Response
*/
public function DevelopExceptionTest() {
throw new DevelopException();
}
}
반응형
'개발 > Laravel' 카테고리의 다른 글
Laravel Dependency Injection Container - 1 (0) | 2020.06.23 |
---|---|
Laravel 6 Auth Login (0) | 2020.06.18 |
Laravel 6 Gmail 연결 및 메일 전송 설정 (2) | 2020.06.09 |
서비스 컨테이너 (0) | 2020.06.08 |
Request 라이프사이클 (0) | 2020.06.05 |