I have written a completely working function that reads PDF Files and scans images for text using an external OCR Library.
I am using fitz to read data from each page as html and bluemonday to parse the html.
There is a weird panic being caused while reading a certain test pdf file (error messages attached)
Is there a way to simply skip execution and return nothing if the function panics? (im not talking about if err != nil checks that happen within the function)
I need a way to return something from my pdf read function in case it panics.
#PDF File Reading In GoLang
13 messages · Page 1 of 1 (latest)
You can use recover to recover from a panic, here are some examples: https://golangbot.com/panic-and-recover/
Are you sure you're not ignoring an error that causes a panic?
nope, every single error is being checked for not nil
and there is a return "", err if it is not nil
im trying to send my code but im unable to
Try to paste it in https://goplay.tools/ and click share if you're not able to paste it in discord
Dunno, could be that whoever wrote the library just decided to panic sometimes instead of returning error
is there a way for me to handle it?
like no matter what goes down just dont panic
something like a try catch
could someone help me with this?