Skip to content

Commit

Permalink
make sonar happy
Browse files Browse the repository at this point in the history
  • Loading branch information
java-coding-prodigy committed Sep 25, 2023
1 parent e83998a commit 078121b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.*;
import org.togetherjava.tjbot.features.mathcommands.wolframalpha.api.Error;

import java.awt.Color;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.net.HttpURLConnection;
import java.net.URISyntaxException;
import java.net.http.HttpResponse;
import java.util.*;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -169,7 +170,7 @@ private HandlerResponse handleSuccessfulResponse(QueryResult queryResult) {
for (SubPod subPod : pod.getSubPods()) {
try {
images.add(WolframAlphaImages.renderSubPod(subPod));
} catch (UncheckedIOException e) {
} catch (IOException | URISyntaxException e) {
LOGGER.error(
"Failed to render sub pod (title: '{}') from pod (title: '{}') from the WolframAlpha response (for query: '{}')",
subPod.getTitle(), pod.getTitle(), query, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static BufferedImage renderTitle(String title) {
return image;
}

static BufferedImage renderSubPod(SubPod subPod) {
static BufferedImage renderSubPod(SubPod subPod) throws IOException, URISyntaxException {
WolframAlphaImage sourceImage = subPod.getImage();

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

try {
graphics.drawImage(ImageIO.read(new URI(sourceImage.getSource()).toURL()),
IMAGE_MARGIN_PX, IMAGE_MARGIN_PX, null);
} catch (IOException | URISyntaxException e) {
throw new RuntimeException(e);
}
graphics.drawImage(ImageIO.read(new URI(sourceImage.getSource()).toURL()), IMAGE_MARGIN_PX,
IMAGE_MARGIN_PX, null);


return destinationImage;
}
Expand Down

0 comments on commit 078121b

Please sign in to comment.