package com.ard.work.component.forest; import com.dtflys.forest.exceptions.ForestRuntimeException; import com.dtflys.forest.http.ForestRequest; import com.dtflys.forest.http.ForestResponse; import com.dtflys.forest.interceptor.ForestInterceptor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @Component @Slf4j public class ErrorInterceptor implements ForestInterceptor { @Override public void onError(ForestRuntimeException ex, ForestRequest request, ForestResponse response) { Throwable cause = ex.getCause(); if (cause instanceof java.net.SocketTimeoutException) { log.error("请求超时 URL:{} ", request.getUrl()); } else { log.error("请求失败 URL:{} {}", request.getUrl(), ex.getMessage()); } } }