package extractcommand;

import extractcommand.step00.Logger;
import extractcommand.step00.AccountServiceException;
import extractcommand.step00.SessionException;

public abstract class AtmCommand<RETURN> {
    protected final RETURN VOID = null;

    private Logger logger;

    protected AtmCommand(Logger logger) {
        this.logger = logger;
    }

    final public RETURN execute() throws SessionException {
        try {
            return doExecute();
        }
        catch (AccountServiceException e) {
            logger.log(e);
            throw new SessionException(e);
        }
        catch (SessionException e) {
            logger.log(e);
            throw e;
        }
    }

    protected abstract RETURN doExecute() throws AccountServiceException, SessionException;
}

