liusuyi
2025-12-26 6bdda41435c30affe62af2bea8861da916c0c56d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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());
        }
    }
 
}