Skip to content

Commit f8994a0

Browse files
committed
using bail instead
Signed-off-by: Aminu 'Seun Joshua <[email protected]>
1 parent e873e9f commit f8994a0

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

crates/trigger-http/src/server.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ impl<F: RuntimeFactors> HttpServer<F> {
158158
addr.set_port(addr.port() + 1);
159159

160160
if !addr.port() == u16::MAX {
161-
return Err(anyhow::anyhow!(
161+
anyhow::bail!(
162162
"Couldn't find a free port as we've reached the maximum port number. Consider retrying with a lower base port."
163-
));
163+
);
164164
}
165165

166166
match TcpListener::bind(addr).await {
@@ -172,10 +172,7 @@ impl<F: RuntimeFactors> HttpServer<F> {
172172
if err.kind() == ErrorKind::AddrInUse {
173173
continue;
174174
}
175-
return Err(anyhow::anyhow!(
176-
"Unable to listen on {}",
177-
self.listen_addr
178-
));
175+
anyhow::bail!("Unable to listen on {}", self.listen_addr);
179176
}
180177
}
181178
}
@@ -186,7 +183,7 @@ impl<F: RuntimeFactors> HttpServer<F> {
186183
self.listen_addr.port() + 9
187184
))?
188185
} else {
189-
return Err(anyhow::anyhow!("Unable to listen on {}. To have Spin search for a free port, use the --find-free-port option.", self.listen_addr));
186+
anyhow::bail!("Unable to listen on {}. To have Spin search for a free port, use the --find-free-port option.", self.listen_addr)
190187
}
191188
}
192189
};

0 commit comments

Comments
 (0)