[Solved] Laravel Error : NotFoundHttpException in RouteCollection.php Example

[Solved] Laravel Error : NotFoundHttpException in RouteCollection.php Example

In this post, i will let you know how to handle Not Found HTTP Exception in Laravel.

This is very common error when you do any mistake in your routing. So as a PHP Developer you should handle all the exception in your running application.

Question is when do you need to use exception and why ?

Exception is an event that occur during the execution of program and disrupt the normal flow of instructions.

In Laravel, there are handler class through which you can handle all the exception in your application.

There are two main methods in Handler class :

report() method is used to log exceptions and render() method is used to convert exception in HTTP response.

You will find the Handler class in following path :App\Exceptions\Handler.php

  1. public function render($request, Exception $e)
  2. {
  3. if ($e instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) {
  4.          // Your stuff here
  5. return response()->view('errors.'.$e->getStatusCode(), [], $e->getStatusCode());
  6. }
  7. return parent::render($request, $e);
  8. }

Now create a 404.blade.php file in following path resources/views/errors to display your own custom message for Not Found HTTP Exception.

Phone: (+91) 8800417876
Noida, 201301
ataşehir escort maltepe escort bostancı escort kadıköy escort maltepe escort ataşehir escort tuzla escort pendik escort ümraniye escort kartal escort
pendik escort
izmir escort izmir escort izmir escort izmir escort denizli escort antalya escort antalya escort antalya escort izmir escort izmir escort izmir escort izmir escort izmir escort
hatay escort nevsehir escort nigde escort kirikkale escort batman escort osmaniye escort kirklareli escort tokat escort rize escort adiyaman escort gumushane escort batman escort
porno izle
sohbet okey oyna
cialis satış cialis fiyat cialis 20 mg cialis 100 mg cialis 5 mg fiyat

viagra fiyatı

viagra 100 mg fiyat

viagra sipariş

orjinal viagra

viagra satın al

izmir escort