So I've started fixing up the services based on this discussion (https://discord.com/channels/648956210850299986/1142913564856832144)
So I changed the abstract classes to an interface and moved the implementation to the real implementation classes. Why am I making this post? Well the service methods are called from the controllers as expected. The service methods throw checked exceptions which I use in the controller to answer different with different responses based on the exception. The problem is that my interface methods look like this:
void saveBusinessUnit(BusinessUnitDTO businessUnitDTO) throws FailedToSaveException;
It looks like something that shouldn't be there but I'm not really sure if what I've made is stupid.
From the top of my head I have 3 solutions.
- Leave it as it is - throws in both the impl and interface requiring anyone who makes a new service impl in the future to have to throw them (probably won't require changes in the controller. But limited in the future in case there is a need to add different exception)
- Remove the throws from both the impl and interface and return a more generic response to the client (Will be hell to debug on why the call failed from the client side)
- Make it a unchecked exception and throw the exception without limiting people to who might want to make a new service (Might lead to tons of confusion and hidden exceptions which aren't handled)
(Nobody would touch the code except me. So just looking to learn how I should go about this. Thanks!)