Skip to content

Commit 57b9916

Browse files
make sonar happy
1 parent ee02662 commit 57b9916

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaHandler.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.*;
1212
import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.Error;
1313

14-
import java.awt.Color;
14+
import java.awt.*;
1515
import java.awt.image.BufferedImage;
1616
import java.io.IOException;
17-
import java.io.UncheckedIOException;
1817
import java.net.HttpURLConnection;
18+
import java.net.URISyntaxException;
1919
import java.net.http.HttpResponse;
2020
import java.util.*;
21+
import java.util.List;
2122
import java.util.function.Function;
2223
import java.util.stream.Collectors;
2324

@@ -169,7 +170,7 @@ private HandlerResponse handleSuccessfulResponse(QueryResult queryResult) {
169170
for (SubPod subPod : pod.getSubPods()) {
170171
try {
171172
images.add(WolframAlphaImages.renderSubPod(subPod));
172-
} catch (UncheckedIOException e) {
173+
} catch (IOException | URISyntaxException e) {
173174
LOGGER.error(
174175
"Failed to render sub pod (title: '{}') from pod (title: '{}') from the WolframAlpha response (for query: '{}')",
175176
subPod.getTitle(), pod.getTitle(), query, e);

application/src/main/java/org/togetherjava/tjbot/features/mathcommands/wolframalpha/WolframAlphaImages.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static BufferedImage renderTitle(String title) {
5454
return image;
5555
}
5656

57-
static BufferedImage renderSubPod(SubPod subPod) {
57+
static BufferedImage renderSubPod(SubPod subPod) throws IOException, URISyntaxException {
5858
WolframAlphaImage sourceImage = subPod.getImage();
5959

6060
int widthPx = sourceImage.getWidth() + 2 * IMAGE_MARGIN_PX;
@@ -64,12 +64,9 @@ static BufferedImage renderSubPod(SubPod subPod) {
6464
new BufferedImage(widthPx, heightPx, BufferedImage.TYPE_4BYTE_ABGR);
6565
Graphics graphics = destinationImage.getGraphics();
6666

67-
try {
68-
graphics.drawImage(ImageIO.read(new URI(sourceImage.getSource()).toURL()),
69-
IMAGE_MARGIN_PX, IMAGE_MARGIN_PX, null);
70-
} catch (IOException | URISyntaxException e) {
71-
throw new RuntimeException(e);
72-
}
67+
graphics.drawImage(ImageIO.read(new URI(sourceImage.getSource()).toURL()), IMAGE_MARGIN_PX,
68+
IMAGE_MARGIN_PX, null);
69+
7370

7471
return destinationImage;
7572
}

0 commit comments

Comments
 (0)