From 1d996b378fae69f39cd9b29ee5133d84c926b25e Mon Sep 17 00:00:00 2001 From: Mayank Jain Date: Sun, 12 Mar 2017 21:21:19 +0530 Subject: [PATCH] Catch NoRouteToHostException exception In case network is down while fetching dependencies and we get NoRouteToHostException exception, fallback to `:offline? true` behaviour. Fixes #2054 issue. --- leiningen-core/src/leiningen/core/classpath.clj | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/leiningen-core/src/leiningen/core/classpath.clj b/leiningen-core/src/leiningen/core/classpath.clj index fb80290b..7227485e 100644 --- a/leiningen-core/src/leiningen/core/classpath.clj +++ b/leiningen-core/src/leiningen/core/classpath.clj @@ -298,10 +298,12 @@ (throw (ex-info "Could not resolve dependencies" {:suppress-msg true :exit-code 1} e))) (catch Exception e - (if (and (instance? java.net.UnknownHostException (root-cause e)) - (not offline?)) - (get-dependencies-memoized dependencies-key (assoc project :offline? true)) - (throw e))))))) + (let [exception-cause (root-cause e)] + (if (and (or (instance? java.net.UnknownHostException exception-cause) + (instance? java.net.NoRouteToHostException exception-cause)) + (not offline?)) + (get-dependencies-memoized dependencies-key (assoc project :offline? true)) + (throw e)))))))) (defn- group-artifact [artifact] (if (= (.getGroupId artifact)