package com.xunmei.system.api.function;

import com.xunmei.common.core.constant.ErrorMsgConstants;
import com.xunmei.common.core.exception.SystemException;
import lombok.extern.slf4j.Slf4j;

/**
 * @author jingyuanchao
 * @date 2023/8/25 17:21
 */
@Slf4j
public class RemoteCallHandlerExecutor {

    public static <T> T executeRemoteCall(RemoteCallHandler<T> handler, String errorMessage) {
        try {
            return handler.handle();
        } catch (Exception e) {
            throw new SystemException(ErrorMsgConstants.REMOTE_CALL_ERROR + errorMessage);
        }
    }
}
