Skip to content

Commit 3f9c2ae

Browse files
committed
refactor: re-wording + logic
Signed-off-by: Aminu 'Seun Joshua <[email protected]>
1 parent 8c26c43 commit 3f9c2ae

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

crates/trigger-http/src/server.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ impl<F: RuntimeFactors> HttpServer<F> {
155155
} else {
156156
TcpListener::bind(self.listen_addr).await.map_err(|err| {
157157
if err.kind() == ErrorKind::AddrInUse {
158-
anyhow::anyhow!("Unable to listen on {}. To have Spin search for a free port, use the --find-free-port option.", self.listen_addr)
158+
anyhow::anyhow!("{} is already in use. To have Spin search for a free port, use the --find-free-port option.", self.listen_addr)
159159
} else {
160-
anyhow::anyhow!("Unable to listen on {}", self.listen_addr)
160+
anyhow::anyhow!("Unable to listen on {}: {err:?}", self.listen_addr)
161161
}
162162
})?
163163
};
@@ -181,14 +181,15 @@ impl<F: RuntimeFactors> HttpServer<F> {
181181
);
182182
}
183183

184-
addr.set_port(addr.port() + 1);
185-
186184
match TcpListener::bind(addr).await {
187185
Ok(listener) => {
188186
found_listener = Some(listener);
189187
break;
190188
}
191-
Err(err) if err.kind() == ErrorKind::AddrInUse => continue,
189+
Err(err) if err.kind() == ErrorKind::AddrInUse => {
190+
addr.set_port(addr.port() + 1);
191+
continue;
192+
}
192193
Err(err) => anyhow::bail!("Unable to listen on {addr}: {err:?}",),
193194
}
194195
}

0 commit comments

Comments
 (0)