{"record":{"id":"f3eae6abd4c8d907","repo":"EllanJiang/GameFramework","slug":"can-not-decompress-with-exception-0","errorCode":null,"errorMessage":"Can not decompress with exception '{0}'.","messagePattern":"Can not decompress with exception '(.+?)'\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Utility/Utility.Compression.cs","lineNumber":281,"sourceCode":"                }\n\n                if (decompressedStream == null)\n                {\n                    throw new GameFrameworkException(\"Decompressed stream is invalid.\");\n                }\n\n                try\n                {\n                    return s_CompressionHelper.Decompress(bytes, offset, length, decompressedStream);\n                }\n                catch (Exception exception)\n                {\n                    if (exception is GameFrameworkException)\n                    {\n                        throw;\n                    }\n\n                    throw new GameFrameworkException(Text.Format(\"Can not decompress with exception '{0}'.\", exception), exception);\n                }\n            }\n\n            /// <summary>\n            /// 解压缩数据。\n            /// </summary>\n            /// <param name=\"stream\">要解压缩的数据的二进制流。</param>\n            /// <returns>是否解压缩数据成功。</returns>\n            public static byte[] Decompress(Stream stream)\n            {\n                using (MemoryStream decompressedStream = new MemoryStream())\n                {\n                    if (Decompress(stream, decompressedStream))\n                    {\n                        return decompressedStream.ToArray();\n                    }\n                    else\n                    {","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Utility/Utility.Compression.cs#L263-L299","documentation":"The Decompress(byte[], int, int, Stream) method wraps any non-GameFramework exception thrown by the compression helper into a GameFrameworkException with the message \"Can not decompress with exception '{0}'.\". The original exception is preserved as InnerException. GameFrameworkException instances are rethrown unchanged.","triggerScenarios":"Any exception (e.g. InvalidDataException, OutOfMemoryException, EndOfStreamException) thrown by s_CompressionHelper.Decompress while decompressing bytes[offset..offset+length] — typically corrupt, truncated, or not-GZip data.","commonSituations":"Passing data that was never compressed, a truncated file download, wrong offset/length slicing the compressed block, or version mismatch between compression and decompression formats.","solutions":["Inspect the InnerException to find the root cause (usually corrupt or truncated data).","Verify the data being decompressed was actually compressed with Utility.Compress.","Confirm offset and length exactly cover the compressed block.","Add checksum/integrity validation on stored or downloaded compressed data."],"exampleFix":"// before\nUtility.Decompress(data, 0, data.Length, output); // throws generic wrapper\n\n// after\ntry\n{\n    Utility.Decompress(data, 0, data.Length, output);\n}\ncatch (GameFrameworkException ex)\n{\n    Debug.LogError($\"Decompress failed: {ex.InnerException}\");\n}","handlingStrategy":"try-catch","validationCode":"if (bytes == null || length <= 0) throw new ArgumentException(\"No compressed data to decompress\");","typeGuard":null,"tryCatchPattern":"try { Utility.Decompress(bytes, offset, length, output); } catch (GameFrameworkException ex) { Debug.LogError($\"Decompress failed: {ex.InnerException}\"); }","preventionTips":["Only decompress data produced by Utility.Compress","Validate checksums on stored/downloaded compressed data","Double-check offset and length bounds against the byte array","Log ex.InnerException, not just the wrapper message"],"tags":["compression","wrapped-exception","corrupt-data"],"backgroundTag":"api-request-failed","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}