 			let capacity = 100_000
 			let destinationBuffer = UnsafeMutablePointer<UInt8>.allocate(capacity: capacity)
 
-			let compressed = data.withUnsafeBytes { (rawBuffer) -> Data? in
+			let compressed = try data.withUnsafeBytes { (rawBuffer) -> Data? in
 				let bound = rawBuffer.bindMemory(to: UInt8.self)
 				let encodedCount = compression_decode_buffer(destinationBuffer, capacity, bound.baseAddress!, rawBuffer.count, nil, rawAlgorithm)
 
 				if encodedCount == 0 {
-					return nil
+					throw UTS46Error.compressionError
 				}
 
 				return Data(bytes: destinationBuffer, count: encodedCount)

	}

	static func write(to url: URL, compression: CompressionAlgorithm = .none) throws {
		guard let data = self.data(compression: compression) else { throw UTS46Error.compressionError }
		try data.write(to: url)
	}


	}

	static func write(to fileHandle: FileHandle, compression: CompressionAlgorithm = .none) throws {
		let data = try self.data(compression: compression)

		if #available(macOS 10.15, iOS 13.0, *) {
			try fileHandle.write(contentsOf: data)
