[Symfony2.8] 客製化(Custom) Exception
- 在路徑 /src/AppBundle/ 下,開一個資料夾 Exception
- 新增檔案 SampleNameException.php
-
<?php namespace AppBundle\Exception; use Throwable; class NotFoundUserException extends \Exception { public function __construct(string $message = "Not Found User", int $code = 100001, Throwable $previous = null) { parent::__construct($message, $code, $previous); } }
-
繼承 Exception 並實作 message 和 code 即可