Skip to content

Commit 1eb8fa1

Browse files
committed
don't show stacktrace for Connection refused exception
1 parent 44e6e00 commit 1eb8fa1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/java/ru/mystamps/web/service/HttpURLConnectionDownloaderService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.io.FileNotFoundException;
2222
import java.io.IOException;
2323
import java.io.InputStream;
24+
import java.net.ConnectException;
2425
import java.net.HttpURLConnection;
2526
import java.net.MalformedURLException;
2627
import java.net.URL;
@@ -146,7 +147,11 @@ private static Code connect(HttpURLConnection conn) {
146147
try {
147148
conn.connect();
148149
return Code.SUCCESS;
149-
150+
151+
} catch (ConnectException ignored) {
152+
LOG.debug("Couldn't download file: connect() has failed");
153+
return Code.UNEXPECTED_ERROR;
154+
150155
} catch (IOException ex) {
151156
LOG.debug("Couldn't download file: connect() has failed", ex);
152157
return Code.UNEXPECTED_ERROR;

0 commit comments

Comments
 (0)