EllanJiang/GameFramework · error · GameFrameworkException

Can not decompress with exception

Error message

Can not decompress with exception '{0}'.

What it means

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.

Solutions

  1. Inspect the InnerException to find the root cause (usually corrupt or truncated data).
  2. Verify the data being decompressed was actually compressed with Utility.Compress.
  3. Confirm offset and length exactly cover the compressed block.
  4. Add checksum/integrity validation on stored or downloaded compressed data.

Example fix

// before
Utility.Decompress(data, 0, data.Length, output); // throws generic wrapper

// after
try
{
    Utility.Decompress(data, 0, data.Length, output);
}
catch (GameFrameworkException ex)
{
    Debug.LogError($"Decompress failed: {ex.InnerException}");
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (bytes == null || length <= 0) throw new ArgumentException("No compressed data to decompress");

Try / catch

try { Utility.Decompress(bytes, offset, length, output); } catch (GameFrameworkException ex) { Debug.LogError($"Decompress failed: {ex.InnerException}"); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/f3eae6abd4c8d907. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Utility/Utility.Compression.cs:281

                }

                if (decompressedStream == null)
                {
                    throw new GameFrameworkException("Decompressed stream is invalid.");
                }

                try
                {
                    return s_CompressionHelper.Decompress(bytes, offset, length, decompressedStream);
                }
                catch (Exception exception)
                {
                    if (exception is GameFrameworkException)
                    {
                        throw;
                    }

                    throw new GameFrameworkException(Text.Format("Can not decompress with exception '{0}'.", exception), exception);
                }
            }

            /// <summary>
            /// 解压缩数据。
            /// </summary>
            /// <param name="stream">要解压缩的数据的二进制流。</param>
            /// <returns>是否解压缩数据成功。</returns>
            public static byte[] Decompress(Stream stream)
            {
                using (MemoryStream decompressedStream = new MemoryStream())
                {
                    if (Decompress(stream, decompressedStream))
                    {
                        return decompressedStream.ToArray();
                    }
                    else
                    {

View on GitHub (pinned to d0c010b051)