|
4 | 4 | import java.io.IOException; |
5 | 5 | import java.net.URI; |
6 | 6 | import java.nio.file.Path; |
| 7 | +import java.util.Arrays; |
7 | 8 | import java.util.Collections; |
8 | 9 | import java.util.Objects; |
9 | 10 | import java.util.concurrent.Callable; |
10 | 11 | import java.util.regex.Matcher; |
11 | 12 | import java.util.regex.Pattern; |
| 13 | +import java.util.stream.Collectors; |
12 | 14 | import lombok.Builder; |
13 | 15 | import lombok.extern.slf4j.Slf4j; |
14 | 16 | import me.itzg.helpers.errors.GenericException; |
@@ -250,20 +252,31 @@ private Mono<Result> downloadUsingCoordinates(PaperDownloadsClient client, Strin |
250 | 252 | String.format("Requested version %s is not available", version)) |
251 | 253 | ) |
252 | 254 | .switchIfEmpty(Mono.error(() -> new InvalidParameterException( |
253 | | - String.format("No build found for version %s with channel %s", version, channel) |
| 255 | + String.format("No build found for version %s with channel '%s'. Perhaps try with a different channel: %s", |
| 256 | + version, channel, channelsExcept(channel)) |
254 | 257 | ))) |
255 | 258 | .flatMap(resolvedBuild -> download(client, project, version, resolvedBuild)); |
256 | 259 | } |
257 | 260 | } |
258 | 261 | else { |
259 | 262 | return client.getLatestVersionBuild(project, channel) |
260 | 263 | .switchIfEmpty( |
261 | | - Mono.error(() -> new InvalidParameterException("No build found with channel " + channel)) |
| 264 | + Mono.error(() -> new InvalidParameterException( |
| 265 | + String.format("No build found with channel '%s'. Perhaps try a different channel: %s", |
| 266 | + channel, channelsExcept(channel) |
| 267 | + ))) |
262 | 268 | ) |
263 | 269 | .flatMap(resolved -> download(client, project, resolved.getVersion(), resolved.getBuild())); |
264 | 270 | } |
265 | 271 | } |
266 | 272 |
|
| 273 | + private String channelsExcept(ReleaseChannel channel) { |
| 274 | + return Arrays.stream(ReleaseChannel.values()) |
| 275 | + .filter(c -> !Objects.equals(c, channel)) |
| 276 | + .map(ReleaseChannel::toString) |
| 277 | + .collect(Collectors.joining(", ")); |
| 278 | + } |
| 279 | + |
267 | 280 | private static boolean isSpecificVersion(String version) { |
268 | 281 | return version != null && !version.equalsIgnoreCase("latest"); |
269 | 282 | } |
|
0 commit comments