Skip to content

Commit

Permalink
improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
tbenr committed Jan 31, 2022
1 parent 6e533e9 commit 2a5b309
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.IOException;
import java.net.URL;
import tech.pegasys.teku.infrastructure.exceptions.InvalidConfigurationException;
import tech.pegasys.teku.infrastructure.http.UrlSanitizer;
import tech.pegasys.teku.provider.JsonProvider;
import tech.pegasys.teku.validator.client.ProposerConfig;

Expand All @@ -34,19 +35,22 @@ public ProposerConfigLoader(final ObjectMapper objectMapper) {

public ProposerConfig getProposerConfig(final File source) {
try {
final ProposerConfig proposerConfig = objectMapper.readValue(source, ProposerConfig.class);
return proposerConfig;
return objectMapper.readValue(source, ProposerConfig.class);
} catch (IOException ex) {
throw new InvalidConfigurationException("Failed to proposer config from File " + source, ex);
throw new InvalidConfigurationException(
"Failed to load proposer config from file: " + source, ex);
}
}

public ProposerConfig getProposerConfig(final URL source) {
try {
final ProposerConfig proposerConfig = objectMapper.readValue(source, ProposerConfig.class);
return proposerConfig;
return objectMapper.readValue(source, ProposerConfig.class);
} catch (IOException ex) {
throw new InvalidConfigurationException("Failed to proposer config from URL " + source, ex);

throw new InvalidConfigurationException(
"Failed to load proposer config from URL:"
+ UrlSanitizer.sanitizePotentialUrl(source.toString()),
ex);
}
}
}

0 comments on commit 2a5b309

Please sign in to comment.