I could recommend another approach that I learned from Spatie - you can just throw exceptions like so (if you have longer exception messages, but not only): `throw CreditsException::notEnoughCredits();` and the underlying implementation is just bunch of static methods doing this: `return new static('Not enough credits in your account');` where static in this case is the exception class. For me it's really neat since you can hide longer messages in the exception class and as well - define some other exceptions that can be related to credits (that way avoiding a ton of exception classes that throw one exception only)! I hope whoever sees this, deems it as useful, because that really helped me with more clarity and more readable exceptions since I like to be descriptive with my exception messages. Cheers!
3 жыл бұрын
Yep I really enjoy this approach as well! Thanks for commenting!
@Flamestriker424 жыл бұрын
This is very helpful. Even if you know how to do custom exception this video still helps. How Laravel handles exception was helpful to me.
4 жыл бұрын
Happy to help!
@mayanksgajjar Жыл бұрын
Hey bro, Its a great content video. You have explained it in a very nice way.... Thanks and keep up doing great work...
Жыл бұрын
It's my pleasure
@jasonennis49054 жыл бұрын
That's some really clean code fham not gonna lie 🇯🇲
4 жыл бұрын
Thanks, Jason!
@bryanastacio51674 жыл бұрын
Really like your content is too specific and helpful, keep going, pal!
@bulent24353 жыл бұрын
That was a good lesson. Thanks.
3 жыл бұрын
Very glad you liked it!
@thevipinchand46904 жыл бұрын
Thanks a ton it's very helpful on daily development.
@murilolivorato14892 жыл бұрын
very good !
@logicalsyntaxerror4 жыл бұрын
Wow, this is very helpful.
4 жыл бұрын
Thanks, man! Much appreciated. 😊
@jongjinkim85873 жыл бұрын
I'm curious why do I have to handle the exception in the controller? Are there any drawbacks in common processing in the handlers provided by Laravel? If you handle exceptions in the controller, there seems to be too many duplicate codes. What do you think?
@mayanksgajjar Жыл бұрын
its just a personal choice, where to write code. I am not writing my business logic directly in controllers. I try to keep it simple. So I try to move my logic in service class, actions class, etc
@loremipsum56424 жыл бұрын
hi, I have a question. What if the custom exception will be placed in the handler?
4 жыл бұрын
I don't particularly like it because if I look at a controller I can't clearly see what happens, but yes, you can place it on the exception handler.
@mubinsayed3 жыл бұрын
Thanks
@hambaku73184 жыл бұрын
Your course's link is not working.
4 жыл бұрын
Whoops. My bad. Try now!
@romeosromo62864 жыл бұрын
Really nice tutorial. However, It would've been really helpful if you showed us the files directories as well as the Ticket file. For new comers to laravel like me, it is not obvious in what directory some files go.
@gugamito4 жыл бұрын
Tem alguma maneira de eu contar quantas exceptions foram geradas?
4 жыл бұрын
Fala, Gustavo. Pode ser mais específico? Acredito que $exception->getTrace() você consegue o stack trace.