Update ocr/google_docai_provider.go

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Icereed 2025-02-10 16:46:35 +01:00 committed by GitHub
parent d71d340eb5
commit 81773d1127
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
}