PhpConcept

Developers Tools

  • Increase font size
  • Default font size
  • Decrease font size
Home PclZip User Guide

PclZip User Guide - Error Handling

Print PDF

Error Handling

Since version 1.3, error handling is integrated inside the PclZip class. Before 1.3 the error handling was done by an external library. The main interest to do that is to be able to distribute PclZip as a single file. It is still possible to use the external error handling (see "Customize PclZip" section).

When a method returns an error code (most of the methods returns 0 on error), the error code, name and sometimes additional informations are available through specific methods :

errorName() : Returns a string containing the name of the error.
errorCode() : Returns the error code value.
errorInfo() : Returns a description associated with the error.

Error handling samples :

Error code reading

$list = $archive->extract(PCLZIP_OPT_PATH, "extract/folder/");
if (
$list == 0) {
die(
"Unrecoverable error, code ".$archive->errorCode());
}


Unrecoverable error, code -6

Error name reading

$list = $archive->extract(PCLZIP_OPT_PATH, "extract/folder/");
if (
$list == 0) {
die(
"Unrecoverable error '".$archive->errorName(). "'");
}


Unrecoverable error 'PCLZIP_ERR_BAD_FORMAT'

Error name and code reading

$list = $archive->extract(PCLZIP_OPT_PATH, "extract/folder/");
if (
$list == 0) {
die(
"Unrecoverable error '".$archive->errorName(true)."'");
}
 
Unrecoverable error 'PCLZIP_ERR_BAD_FORMAT(-10)'

Error description reading

$list = $archive->extract(PCLZIP_OPT_PATH, "extract/folder/");
if (
$list == 0) {
die(
"Error : '".$archive->errorInfo()."'");
}

Error : 'Invalid archive structure [code -10]'

Full error description reading

$list = $archive->extract(PCLZIP_OPT_PATH, "extract/folder/");
if (
$list == 0) {
die(
"Error : '".$archive->errorInfo(true)."'");
}

Error : 'PCLZIP_ERR_BAD_FORMAT(-10) : Invalid archive structure'

 

Class and Methods [Table Of Content] Customize PclZip

 

Last Updated on Tuesday, 15 December 2009 08:39