1. Jeff Hardy
  2. IronPython.Zlib

Source

IronPython.Zlib / src / Compress.cs

Diff from to

File src/Compress.cs

         {
             zst = new ZStream();
             int err = zst.deflateInit(level, wbits);
+            switch(err)
+            {
+                case ZlibModule.Z_OK:
+                    break;
 
-            if(err != Z_OK)
-            {
-                throw PythonOps.ValueError("Could not initialize deflate.");
+                case ZlibModule.Z_STREAM_ERROR:
+                    throw PythonOps.ValueError("Invalid initialization option");
+
+                default:
+                    throw ZlibModule.zlib_error(this.zst, err, "while creating compression object");
             }
         }
 
 
             if(err != Z_OK && err != Z_BUF_ERROR)
             {
-                throw PythonOps.ValueError("deflate error.");
+                throw ZlibModule.zlib_error(this.zst, err, "while compressing");
             }
 
             return ZlibModule.Latin1.GetString(output, 0, (int)(zst.total_out - start_total_out));
                 err = zst.deflateEnd();
                 if(err != Z_OK)
                 {
-                    throw PythonOps.ValueError("Error finishing deflate.");
+                    throw ZlibModule.zlib_error(this.zst, err, "from deflateEnd()");
                 }
             }
             else if(err != Z_OK && err != Z_BUF_ERROR)
             {
-                throw ZlibModule.MakeError("deflate error");
+                throw ZlibModule.zlib_error(this.zst, err, "while flushing");
             }
 
             return ZlibModule.Latin1.GetString(output, 0, (int)(zst.total_out - start_total_out));