I have some data that I'm compressing & converting to a base 64 string and then sending to a server.
When i then fetch that data from the server and decompress it, the data usually decodes & decompresses fine, but for an occasional reading it will throw an error. Is there a way to find out more information about what part of the decompression process is failing?
Compressing:
let encodedCompressedReadings = try? (readings.toData() as NSData).compressed(using: .zlib).base64EncodedString()
Decompressing:
if let decodedCompressedReadings = Data(base64Encoded: encodedCompressedReadings) {
do {
let decodedDecompressedReadings = try (decodedCompressedReadings as NSData).decompressed(using: .zlib)
...
} catch {
print(error) // Error Domain=NSCocoaErrorDomain Code=5377 "(null)"
print(error.localizedDescription) // The operation couldn’t be completed. (Cocoa error 5377.)
print(NSDecompressionFailedError) // 5377
}
}