Skip to content

Commit ef52e13

Browse files
committed
Improve error messages around Mix TCP failures, closes #14912
1 parent 8fb1ddf commit ef52e13

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

lib/mix/lib/mix/pubsub/subscriber.ex

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,15 @@ defmodule Mix.PubSub.Subscriber do
2121
@impl true
2222
def init({}) do
2323
build_path = Mix.Project.build_path()
24-
Mix.Sync.PubSub.subscribe(build_path)
25-
{:ok, %{acc: []}}
24+
25+
case Mix.Sync.PubSub.subscribe(build_path) do
26+
:ok ->
27+
{:ok, %{acc: []}}
28+
29+
{:error, message} ->
30+
IO.warn(message, [])
31+
:ignore
32+
end
2633
end
2734

2835
@impl true

lib/mix/lib/mix/sync/lock.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ defmodule Mix.Sync.Lock do
153153
end
154154

155155
{:error, reason} ->
156-
Mix.raise(
157-
"failed to open a TCP socket while acquiring a lock, reason: #{inspect(reason)}"
158-
)
156+
Mix.raise("failed to acquire filesystem lock using TCP, reason: #{inspect(reason)}")
159157
end
160158
end
161159

lib/mix/lib/mix/sync/pubsub.ex

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ defmodule Mix.Sync.PubSub do
4444
"""
4545
@spec subscribe(String.t()) :: :ok
4646
def subscribe(key) do
47-
case GenServer.call(@name, {:subscribe, self(), key}, :infinity) do
48-
:ok -> :ok
49-
{:error, message} -> Mix.raise(message)
50-
end
47+
GenServer.call(@name, {:subscribe, self(), key}, :infinity)
5148
end
5249

5350
@doc """
@@ -201,8 +198,7 @@ defmodule Mix.Sync.PubSub do
201198
{:ok, %{state | port: port}}
202199

203200
{:error, reason} ->
204-
{:error,
205-
"failed to open a TCP socket in #{inspect(__MODULE__)}.subscribe/1, reason: #{inspect(reason)}"}
201+
{:error, "failed to subscribe to Mix events using TCP, reason: #{inspect(reason)}"}
206202
end
207203
end
208204

0 commit comments

Comments
 (0)