Skip to content

Commit

Permalink
Better error logger
Browse files Browse the repository at this point in the history
  • Loading branch information
hauck-jvsh committed Feb 22, 2025
1 parent 2052b63 commit 9d918a4
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -192,7 +193,14 @@ private void sendZipFile(File zipFile) throws IOException {
}

} else {
logger.error("Failed to upload ZIP. HTTP Code: {}", statusCode);
String errorMessage;
try (InputStream errorStream = response.getEntity().getContent()) {
errorMessage = new String(errorStream.readAllBytes(), StandardCharsets.UTF_8);
} catch (IOException e) {
errorMessage = "Failed to read error message from response.";
}

logger.error("Failed to upload ZIP. HTTP Code: {} - Response: {}", statusCode, errorMessage);
}
}
}
Expand All @@ -212,9 +220,8 @@ protected void process(IItem evidence) throws Exception {
sendItemsToNextTask();
return;
}
// TODO Auto-generated method stub
if (!isEnabled() || !evidence.isToAddToCase() || evidence.getHashValue() == null || evidence.getThumb() == null
|| evidence.isQueueEnd()) {
|| evidence.getThumb().length < 10 || evidence.isQueueEnd()) {
return;
}
String name = evidence.getExtraAttribute(IndexItem.TRACK_ID).toString() + ".jpg";
Expand Down

0 comments on commit 9d918a4

Please sign in to comment.