package by.bsuir.mpp.computershop.controller.exception.wrapper;

import by.bsuir.mpp.computershop.controller.exception.ControllerException;
import by.bsuir.mpp.computershop.controller.exception.ResourceNotFoundException;
import by.bsuir.mpp.computershop.utils.WrappedFunctions.Function;
import by.bsuir.mpp.computershop.utils.WrappedFunctions.VoidFunction;
import by.bsuir.mpp.computershop.service.exception.EntityNotFoundException;
import by.bsuir.mpp.computershop.service.exception.ServiceException;
import org.apache.log4j.Logger;

public class ServiceCallWrapper {
    public static <T> T wrapServiceCall(Function<T> func, Logger logger) throws ControllerException {
        T result;
        try {
            result = func.call();
        } catch (EntityNotFoundException e) {
            logger.warn(e);
            throw new ResourceNotFoundException(e);
        } catch (ServiceException e) {
            logger.warn(e);
            throw new ControllerException(e);
        }
        return result;
    }

    public static void wrapServiceCall(VoidFunction func, Logger logger) throws ControllerException {
        wrapServiceCall(() -> func, logger);
    }
}

@@ -251,35 +251,45 @@
 hop.
-utils.WrappedFunctions.Func
+service.exception.EntityNotFoundExcep
 tion
@@ -327,39 +327,38 @@
 hop.
-utils.WrappedFunctions.VoidFunc
+service.exception.ServiceExcep
 tion
@@ -396,45 +396,35 @@
 hop.
-service.exception.EntityNotFoundExcep
+utils.WrappedFunctions.Func
 tion
@@ -462,38 +462,39 @@
 hop.
-service.exception.ServiceExcep
+utils.WrappedFunctions.VoidFunc
 tion
@@ -1141,20 +1141,77 @@
 l(() -%3E 
-func
+%7B%0A            func.call();%0A            return null;%0A        %7D
 , logger

Fix error with Service Calls Wrapper