Answer the question
In order to leave comments, you need to log in
Why doesn't the exception work?
Exception
namespace App\Exceptions;
use Exception;
use Illuminate\Support\Facades\Log;
class ResizeDirNotFoundException extends Exception
{
public function report(Exception $exception)
{
Log::error('Resize dir is empty');
parent::report($exception);
}
}
private function validateResizeParams($params)
{
if (empty($params['dirForSave'])) {
throw new ResizeDirNotFoundException('Resize dir is empty');
}
}
public function resize($width, $height, $dirForSave, $quality = 100)
{
$params = [
'width' => $width,
'height' => $height,
'dirForSave' => $dirForSave
];
try {
if (!is_null($this->file) && $this->validateResizeParams($params)) {
//resize
}
} catch (Exception $exception) {
return redirect('/');
}
}
Answer the question
In order to leave comments, you need to log in
The exception itself works, but you need to remove the report method, because the class Extension
does not contain it.
To
make the redirect work, you need to replace with
return redirect('/');
redirect('/')->send();
What should have happened?
You catch eksepsheny. } catch (Exception $exception) {
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question