package com.yeejoin.amos.boot.biz.common.feign;

import feign.Response;
import feign.Util;
import feign.codec.ErrorDecoder;

import java.io.IOException;

/**
 * @description:
 * @author: tw
 * @createDate: 2023/8/1
 */
public class FeignErrorDecoder implements ErrorDecoder {

    @Override
    public Exception decode(String s, Response response) {
        String msg = null;
        try {
            msg = Util.toString(response.body().asReader());
        } catch (IOException e) {
            e.printStackTrace();
        }
        throw new RuntimeException(msg);
    }
}
