From 3623915d52a9769a5cb40ad8f9ae3d0995fe4ee6 Mon Sep 17 00:00:00 2001
From: Thomas Heller
Date: Thu, 28 Feb 2019 09:26:17 +0100
Subject: [PATCH] shorten error message when dev-http port is taken
fixes #450
---
src/main/shadow/cljs/devtools/server/dev_http.clj | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/main/shadow/cljs/devtools/server/dev_http.clj b/src/main/shadow/cljs/devtools/server/dev_http.clj
index a1343f78..5a9620cf 100644
--- a/src/main/shadow/cljs/devtools/server/dev_http.clj
+++ b/src/main/shadow/cljs/devtools/server/dev_http.clj
@@ -12,7 +12,8 @@
[shadow.http.push-state :as push-state]
[clojure.string :as str])
(:import [io.undertow.server HttpHandler ExchangeCompletionListener]
- [shadow.undertow ShadowResourceHandler]))
+ [shadow.undertow ShadowResourceHandler]
+ [java.net BindException]))
(defmethod undertow/build* ::file-recorder [state [id {:keys [on-request] :as props} next]]
(assert (vector? next))
@@ -129,7 +130,12 @@
(let [srv (try
(undertow/start http-options handler-config)
(catch Exception e
- (log/warn-ex e ::http-start-ex {:http-options http-options :config config})
+ (cond
+ (instance? BindException (.getCause e))
+ (log/warn :shadow.cljs.devtools.server/tcp-port-unavailable {:port port})
+
+ :else
+ (log/warn-ex e ::http-start-ex {:http-options http-options :config config}))
nil))]
(cond
(some? srv)