Skip to content

Commit 5a5e3e2

Browse files
committed
Catch any exception with debug
1 parent 7db9a10 commit 5a5e3e2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/java/xyz/srnyx/javautilities/HttpUtility.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.jetbrains.annotations.Nullable;
99

1010
import java.io.BufferedReader;
11-
import java.io.IOException;
1211
import java.io.InputStreamReader;
1312
import java.net.HttpURLConnection;
1413
import java.net.URI;
@@ -50,7 +49,7 @@ public static <T> Optional<T> get(@NotNull String userAgent, @NotNull String url
5049
return Optional.empty();
5150
}
5251
result = function.apply(new InputStreamReader(connection.getInputStream()));
53-
} catch (final IOException e) {
52+
} catch (final Exception e) {
5453
if (DEBUG) e.printStackTrace();
5554
}
5655
if (connection != null) connection.disconnect();
@@ -107,7 +106,7 @@ public static int postJson(@NotNull String userAgent, @NotNull String urlString,
107106
if (connectionConsumer != null) connectionConsumer.accept(connection);
108107
if (data != null) connection.getOutputStream().write(data.toString().getBytes());
109108
responseCode = connection.getResponseCode();
110-
} catch (final IOException e) {
109+
} catch (final Exception e) {
111110
if (DEBUG) e.printStackTrace();
112111
}
113112
if (connection != null) connection.disconnect();
@@ -136,7 +135,7 @@ public static int putJson(@NotNull String userAgent, @NotNull String urlString,
136135
if (connectionConsumer != null) connectionConsumer.accept(connection);
137136
if (data != null) connection.getOutputStream().write(data.toString().getBytes());
138137
responseCode = connection.getResponseCode();
139-
} catch (final IOException e) {
138+
} catch (final Exception e) {
140139
if (DEBUG) e.printStackTrace();
141140
}
142141
if (connection != null) connection.disconnect();
@@ -161,7 +160,7 @@ public static int delete(@NotNull String userAgent, @NotNull String urlString, @
161160
connection.setRequestProperty("User-Agent", userAgent);
162161
if (connectionConsumer != null) connectionConsumer.accept(connection);
163162
responseCode = connection.getResponseCode();
164-
} catch (final IOException e) {
163+
} catch (final Exception e) {
165164
if (DEBUG) e.printStackTrace();
166165
}
167166
if (connection != null) connection.disconnect();

0 commit comments

Comments
 (0)