From 2a5b309c37e7799e6282e0112ccd0a96c1049159 Mon Sep 17 00:00:00 2001 From: Enrico Del Fante Date: Thu, 27 Jan 2022 18:06:01 +0100 Subject: [PATCH] improve error messages --- .../loader/ProposerConfigLoader.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader/ProposerConfigLoader.java b/validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader/ProposerConfigLoader.java index 63a5c3cb32a..291be3dba0b 100644 --- a/validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader/ProposerConfigLoader.java +++ b/validator/client/src/main/java/tech/pegasys/teku/validator/client/proposerconfig/loader/ProposerConfigLoader.java @@ -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; @@ -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); } } }