Reputation: 11
I am using laravel Local Filesystem.
how to throw custom exception if there no directory when using file system. I want make new message like "no Folder found" or any custom
mkdir(): No such file or directory
I want to create custom exception when running Storage::disk('local')->Files('/no folder/);
or when setting custom disk 'root' => "D:/No Folder/",
Upvotes: 0
Views: 1116
Reputation: 633
Here is a guide on creating your own PHP exception with the Laravel framework:
<?php
namespace App\Exceptions;
class MyCustomException extends \Exception { }
throw new App\Exceptions\MyCustomException('My own message here');
You can read more about exceptions here, and about extending exceptions here. If you want to extend an existing, built-in, exception; here is a useful page for finding which one you want to extend.
If you just want to throw a regular exception with your own message, just use throw new \Exception('My own message here');
Upvotes: 0