Added more detailed error handling (#1922)

This commit is contained in:
Andy Miller
2018-03-18 11:56:59 -06:00
committed by GitHub
parent dce97221c5
commit 40e7ee79b4

View File

@@ -189,10 +189,59 @@ class Installer
return $extracted_folder;
}
self::$error = self::ZIP_EXTRACT_ERROR;
self::$error = self::getZipError($archive);
return false;
}
/**
* Output a more useful ZIP error
*
* @param $res
* @return string
*/
protected static function getZipError($res)
{
switch($res){
case ZipArchive::ER_EXISTS:
$error = "File already exists.";
break;
case ZipArchive::ER_INCONS:
$error = "Zip archive inconsistent.";
break;
case ZipArchive::ER_MEMORY:
$error = "Malloc failure.";
break;
case ZipArchive::ER_NOENT:
$error = "No such file.";
break;
case ZipArchive::ER_NOZIP:
$error = "Not a zip archive.";
break;
case ZipArchive::ER_OPEN:
$error = "Can't open file.";
break;
case ZipArchive::ER_READ:
$error = "Read error.";
break;
case ZipArchive::ER_SEEK:
$error = "Seek error.";
break;
default:
$error = self::ZIP_EXTRACT_ERROR;
break;
}
return $error;
}
/**
* Instantiates and returns the package installer class