From 81773d112750356641c2f22748734bf57e2d4803 Mon Sep 17 00:00:00 2001 From: Icereed Date: Mon, 10 Feb 2025 16:46:35 +0100 Subject: [PATCH] Update ocr/google_docai_provider.go Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- ocr/google_docai_provider.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ocr/google_docai_provider.go b/ocr/google_docai_provider.go index 1ed8ae9..2121a71 100644 --- a/ocr/google_docai_provider.go +++ b/ocr/google_docai_provider.go @@ -106,7 +106,15 @@ func (p *GoogleDocAIProvider) ProcessImage(ctx context.Context, imageContent []b // Add hOCR output if available if len(resp.Document.GetPages()) > 0 { - hocr := generateHOCR(resp.Document) + var hocr string + func() { + defer func() { + if r := recover(); r != nil { + logger.WithField("error", r).Error("Panic during hOCR generation") + } + }() + hocr = generateHOCR(resp.Document) + }() if hocr != "" { result.HOCR = hocr }