| 2245 | } |
| 2246 | |
| 2247 | private RuntimeException mapNetworkException(Throwable e, String method, String url) { |
| 2248 | // Unwrap CompletionException if needed |
| 2249 | Throwable cause = e; |
| 2250 | while (cause instanceof java.util.concurrent.CompletionException && cause.getCause() != null) { |
| 2251 | cause = cause.getCause(); |
| 2252 | } |
| 2253 | if (cause instanceof java.net.http.HttpTimeoutException) { |
| 2254 | String errorMessage = this.id + " " + method + " " + url + " " + cause.getMessage(); |
| 2255 | return new RequestTimeout(errorMessage); |
| 2256 | } |
| 2257 | if (cause instanceof java.net.ConnectException |
| 2258 | || cause instanceof java.net.UnknownHostException |
| 2259 | || cause instanceof java.net.SocketException |
| 2260 | || cause instanceof java.io.IOException) { |
| 2261 | String errorMessage = this.id + " " + method + " " + url + " " + cause.getMessage(); |
| 2262 | return new NetworkError(errorMessage); |
| 2263 | } |
| 2264 | if (cause instanceof RuntimeException) { |
| 2265 | return (RuntimeException) cause; |
| 2266 | } |
| 2267 | return new RuntimeException(cause); |
| 2268 | } |
| 2269 | |
| 2270 | public CompletableFuture<Object> fetch(Object url2, Object method2, Object headers2) { |
| 2271 | return fetch(url2, method2, headers2, null); |