fix: show error for PDFs without chapters

This commit is contained in:
Anthony Stirling 2025-06-02 17:17:24 +01:00
parent 631c4fef0b
commit a611ea5109

View File

@ -131,7 +131,7 @@ public class SplitPdfByChaptersController {
Integer bookmarkLevel = Integer bookmarkLevel =
request.getBookmarkLevel(); // levels start from 0 (top most bookmarks) request.getBookmarkLevel(); // levels start from 0 (top most bookmarks)
if (bookmarkLevel < 0) { if (bookmarkLevel < 0) {
return ResponseEntity.badRequest().body("Invalid bookmark level".getBytes()); throw new IllegalArgumentException("Invalid bookmark level");
} }
sourceDocument = pdfDocumentFactory.load(file); sourceDocument = pdfDocumentFactory.load(file);
@ -139,7 +139,7 @@ public class SplitPdfByChaptersController {
if (outline == null) { if (outline == null) {
log.warn("No outline found for {}", file.getOriginalFilename()); log.warn("No outline found for {}", file.getOriginalFilename());
return ResponseEntity.badRequest().body("No outline found".getBytes()); throw new IllegalArgumentException("No outline found");
} }
List<Bookmark> bookmarks = new ArrayList<>(); List<Bookmark> bookmarks = new ArrayList<>();
try { try {