Could remove this detailed error checking (L113-123) and just replace it with something simple that says the file must be corrupt / couldn't decode