In our previous article we have discussed about Functions gzseek in Zlib, which is utility function. If you have not gone through that , please take a look on clicking this link Python zlib gzseek();
Now in this article we will discuss about gzerror function .This article will specifically give you a brief idea about gzerror in zlib.
gzerror const char * gzerror (gzFile file, int *errnum);
decode an error on a compressed file stream
The gzerror() function shall return a string describing the last error to have occurred associated with the open compressed file stream referred to by file. It shall also set the location referenced by errnum to an integer value that further identifies the error.
Returns the error message for the last error which occurred on the given compressed file. errnum is set to zlib error number. If an error occurred in the file system and not in the compression library, errnum is set to Z_ERRNO and the application may consult errno to get the exact error code.
The application must not modify the returned string. Future calls to this function may invalidate the previously returned string. If file is closed, then the string previously returned by gzerror will no longer be available.
The gzerror() function shall return a string that describes the last error associated with the given file compressed file stream. This string shall have the format "%s: %s", with the name of the file, followed by a colon, a space, and the description of the error. If the compressed file stream was opened by a call to gzdopen(), the format of the filename is unspecified.
Rationale: Although in all current implementations of libz file descriptors are named "<fd:%d>", the code suggests that this is for debugging purposes only, and may change in a future release.
It is unspecified if the string returned is determined by the setting of the LC_MESSAGES category in the current locale.
gzerror() should be used to distinguish errors from end-of-file for those functions above that do not distinguish those cases in their return values.