Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print an error message when the downloader configuration file is missing. #20061

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ public void beforeCommand(CommandEnvironment env) throws AbruptExitException {
throw new AbruptExitException(
detailedExitCode(
String.format(
"Failed to parse downloader config at %s: %s", e.getLocation(), e.getMessage()),
"Failed to parse downloader config%s: %s",
e.getLocation() != null ? String.format(" at %s", e.getLocation()) : "",
e.getMessage()),
Code.BAD_DOWNLOADER_CONFIG));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.UncheckedIOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -98,7 +97,7 @@ public static UrlRewriter getDownloaderUrlRewriter(String configPath, Reporter r
try (BufferedReader reader = Files.newBufferedReader(Paths.get(configPath))) {
return new UrlRewriter(log, configPath, reader);
} catch (IOException e) {
throw new UncheckedIOException(e);
throw new UrlRewriterParseException(e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,27 @@
// limitations under the License.
package com.google.devtools.build.lib.bazel.repository.downloader;

import javax.annotation.Nullable;
import net.starlark.java.syntax.Location;

/** An {@link Exception} thrown when failed to parse {@link UrlRewriterConfig}. */
/**
* An {@link Exception} thrown when failed to parse {@link UrlRewriterConfig}.
*/
public class UrlRewriterParseException extends Exception {

@Nullable
private final Location location;

public UrlRewriterParseException(String message, Location location) {
public UrlRewriterParseException(String message) {
this(message, /* location= */ null);
}

public UrlRewriterParseException(String message, @Nullable Location location) {
super(message);
this.location = location;
}

@Nullable
public Location getLocation() {
return location;
}
Expand Down
Loading