The proper way to do exception handling
问题 Now what I generally do when writing code is something like this function changeBookAuthor(int $id, string $newName){ if(!$newName){ throw new MyAppException('No author name was provided'); } $book = Books::find($id); if(!$book){ throw new MyAppException('The provided book id could not be found'); } } in the laravel doc we see: https://laravel.com/docs/5.4/errors public function report(Exception $exception) { if ($exception instanceof CustomException) { // } return parent::report($exception);