From baed9dc6cc9975493277efa629da5ece05959fae Mon Sep 17 00:00:00 2001 From: shicong Date: Thu, 4 Apr 2019 12:37:00 -0700 Subject: [PATCH] Improve exception message when TMDB not available We saw a few IOExceptions recently which indicated that TMDB may be down at that time. However, these IOExceptions didn't have any message to clearly describe that. This CL is to improve the exception message so next time we don't have to look at the source code to figure out what happened. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=241984023 --- java/google/registry/tmch/Marksdb.java | 8 +++++++- java/google/registry/tmch/NordnUploadAction.java | 8 +++++++- java/google/registry/tmch/NordnVerifyAction.java | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/java/google/registry/tmch/Marksdb.java b/java/google/registry/tmch/Marksdb.java index 17ae96a91..7afe5b459 100644 --- a/java/google/registry/tmch/Marksdb.java +++ b/java/google/registry/tmch/Marksdb.java @@ -115,7 +115,13 @@ public final class Marksdb { byte[] fetch(URL url, Optional loginAndPassword) throws IOException { HTTPRequest req = new HTTPRequest(url, GET, validateCertificate().setDeadline(60d)); setAuthorizationHeader(req, loginAndPassword); - HTTPResponse rsp = fetchService.fetch(req); + HTTPResponse rsp; + try { + rsp = fetchService.fetch(req); + } catch (IOException e) { + throw new IOException( + String.format("Error connecting to MarksDB at URL %s", url), e); + } if (rsp.getResponseCode() != SC_OK) { throw new UrlFetchException("Failed to fetch from MarksDB", req, rsp); } diff --git a/java/google/registry/tmch/NordnUploadAction.java b/java/google/registry/tmch/NordnUploadAction.java index 2af5261c6..ffe166542 100644 --- a/java/google/registry/tmch/NordnUploadAction.java +++ b/java/google/registry/tmch/NordnUploadAction.java @@ -191,7 +191,13 @@ public final class NordnUploadAction implements Runnable { HTTPRequest req = new HTTPRequest(new URL(url), POST, validateCertificate().setDeadline(60d)); lordnRequestInitializer.initialize(req, tld); setPayloadMultipart(req, "file", "claims.csv", CSV_UTF_8, csvData, random); - HTTPResponse rsp = fetchService.fetch(req); + HTTPResponse rsp; + try { + rsp = fetchService.fetch(req); + } catch (IOException e) { + throw new IOException( + String.format("Error connecting to MarksDB at URL %s", url), e); + } if (logger.atInfo().isEnabled()) { String response = (rsp.getContent() == null) ? "(null)" : new String(rsp.getContent(), US_ASCII); diff --git a/java/google/registry/tmch/NordnVerifyAction.java b/java/google/registry/tmch/NordnVerifyAction.java index fb847852b..f35036780 100644 --- a/java/google/registry/tmch/NordnVerifyAction.java +++ b/java/google/registry/tmch/NordnVerifyAction.java @@ -98,7 +98,13 @@ public final class NordnVerifyAction implements Runnable { logger.atInfo().log("LORDN verify task %s: Sending request to URL %s.", actionLogId, url); HTTPRequest req = new HTTPRequest(url, GET, validateCertificate().setDeadline(60d)); lordnRequestInitializer.initialize(req, tld); - HTTPResponse rsp = fetchService.fetch(req); + HTTPResponse rsp; + try { + rsp = fetchService.fetch(req); + } catch (IOException e) { + throw new IOException( + String.format("Error connecting to MarksDB at URL %s", url), e); + } logger.atInfo().log( "LORDN verify task %s response: HTTP response code %d, response data: %s", actionLogId, rsp.getResponseCode(), rsp.getContent());