Is it okay to throw exceptions and errors from not controller or request class in Laravel or in general?

160 Views Asked by At

Is it okay to throw exceptions and errors from not controller or request class in Laravel or in general ?

I have a lot of business logic in my "Repository" class, where I put code to work with data and the database (through Eloquent models). It's kind of an abstraction to avoid cluttering the Eloquent class directly. I am not a master when it comes to building architecture, programming principles, and programming patterns; I'm still learning. So, my question is: Is it okay to throw an exception or error from a method in the Repository or some other Helper class that handles some logic? I don't know where I heard that these kinds of things should only be handled in the controller class. So, I need a piece of advice on this, and thank you for your time!

0

There are 0 best solutions below