• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 11125885738

01 Oct 2024 01:02PM UTC coverage: 66.509% (-0.02%) from 66.525%
11125885738

push

github

web-flow
#525: Added online state check before downloading (#610)

2331 of 3846 branches covered (60.61%)

Branch coverage included in aggregate %.

6119 of 8859 relevant lines covered (69.07%)

3.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

37.5
cli/src/main/java/com/devonfw/tools/ide/cli/CliOfflineException.java
1
package com.devonfw.tools.ide.cli;
2

3
import java.net.URL;
4
import java.nio.file.Path;
5

6
import com.devonfw.tools.ide.process.ProcessResult;
7
import com.devonfw.tools.ide.version.VersionIdentifier;
8

9
/**
10
 * {@link CliException} that is thrown if further processing requires network but the user if offline.
11
 */
12
public final class CliOfflineException extends CliException {
13

14
  /**
15
   * The constructor.
16
   */
17
  public CliOfflineException() {
18

19
    super("You are offline but network connection is required to perform the operation.", ProcessResult.OFFLINE);
×
20
  }
×
21

22
  /**
23
   * The constructor.
24
   *
25
   * @param message the {@link #getMessage() message}.
26
   */
27
  private CliOfflineException(String message) {
28
    super(message, ProcessResult.OFFLINE);
4✔
29
  }
1✔
30

31
  /**
32
   * Factory method, which is called, when trying to download via a URL
33
   *
34
   * @param url the url, which the software should be downloaded from.
35
   * @return A {@link CliOfflineException} with an informative message.
36
   */
37
  public static CliOfflineException ofDownloadViaUrl(String url) {
38
    return new CliOfflineException("You are offline and cannot download from URL " + url);
×
39
  }
40

41
  /**
42
   * Factory method, which is called, when trying to download via tool name, edition and version
43
   *
44
   * @param tool the name of the tool, we want to download.
45
   * @param edition the edition of the tool, we want to download.
46
   * @param version the {@link VersionIdentifier} of the tool, we want to download.
47
   * @return A {@link CliOfflineException} with an informative message.
48
   */
49
  public static CliOfflineException ofDownloadOfTool(String tool, String edition, VersionIdentifier version) {
50
    return new CliOfflineException("Not able to download tool " + tool + " in edition " + edition + " with version " + version + " because we are offline");
×
51
  }
52

53
  /**
54
   * Factory method, which is called, when just a purpose is given.
55
   *
56
   * @param purpose the purpose, which the internet connection serves.
57
   * @return A {@link CliOfflineException} with an informative message.
58
   */
59
  public static CliOfflineException ofPurpose(String purpose) {
60
    return new CliOfflineException("You are offline but Internet access is required for " + purpose);
×
61
  }
62

63
  /**
64
   * Factory method, which is called, when a clone is performed in offline mode
65
   *
66
   * @param url the url, in which the clone should be executed.
67
   * @param repository the path, where the repository should be cloned to.
68
   * @return A {@link CliOfflineException} with an informative message.
69
   */
70
  public static CliOfflineException ofClone(URL url, Path repository) {
71
    return new CliOfflineException("Could not clone " + url + " to " + repository + " because you are offline.");
7✔
72
  }
73

74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc