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 }