Yes you can let laravel handle errors, however see the error chapter, usually have a message or firendly page to redirect to. It will be in the chapter on errors, all of this.
Need to Know about Laravel Exception Handling BEST PRACTICE
I m newbie for Laravel .
I' m planning to develop Laravel CRUD based web application using Laravel. its Member's management system.
I want to use SOLID principles in this application. So I DO NOT want to make complexity of controller Class.
Is that possible me to handle CRUD operation's exceptions without using try{} catch() block. if YES , then how . if NO , please suggest me good practice.
@Amrith I have written business apps and never needed to add a try catch, not including catching for javascript.
I may have something like this:
if ($validator->fails()) {
return response()->json($validator->errors(), 422);
}
And in code have:
if (response.status === 422) {
response.json().then(function (data) {
var div = document.getElementById('msg');
for (var key in data) {
div.innerHTML += data[key];
}
})
}
Display the errors in a division. But laravel handles errors well and in non ajax you can return with errors.
I'm sure some custom code in a custom helper you may want to add a try catch, but regular CRUD I have never needed.
Edit:
Have you viewed the free laravel from scratch series by @jeffreyway?
Please or to participate in this conversation.