jeudi 29 décembre 2016

How to handle Not Found Resource?

when i try to visit a deleted image url i got this :

The requested resource /storage/images/5865c6789d48d96dd04ad92e7f7.jpeg was not found on this server.

So how can i handle this error or exception, so i can return formatted json instead.

I tried to handle FileNotFoundException at app\Exceptions\Handler but it didn't work

public function report(Exception $exception)
{
  if ($exception instanceof FileNotFoundException) {
    dd(json_encode['message'=>'file not found']);
  }

    parent::report($exception);
}

Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2hz4uzj
via IFTTT

Aucun commentaire:

Enregistrer un commentaire