Godot Version
Godot Version 4.4
Question
Hi there, I’m currently writing a program that takes JPG input from another program. I am drawing JPG input from this program many times a second. To preface this, my program works perfectly fine as intended. However, what’s troubling me is that the function “load_jpg_from_buffer(buffer)” is filling my debugger with Errors with every run of the program.

This error is always an ERR_PARSE_ERROR due to how the JPG loaded may be corrupted as it has not fully been saved by the other program. However, I cannot know if the JPG is corrupted without first checking if it’s corrupted with the function, which prints an error message to the debugger.
My workaround for now is to limit the number of error messages a second to give myself a small piece of mind. Would anyone know of a way to ignore this error? Otherwise, would anyone know of a better way to check whether the external file is finished saving and only loading it then?
var fileName : String = "../images/" + parseStr.substr(0, strLength - decimal) + str(fileNum) + ".jpg"
var jpg = FileAccess.open(fileName, FileAccess.READ)
if jpg == null:
print("Error opening file: ", fileName)
return null
if jpg.get_length() < 100000:
print("Jpg too small")
return null
var buffer = jpg.get_buffer(jpg.get_length())
var tempError = tempImage.load_jpg_from_buffer(buffer)
if tempError != OK:
print("Error Code: ", tempError)
return null
```