Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+73 -14
View File
@@ -11,7 +11,7 @@
namespace IPS\File;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -23,14 +23,38 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
class _Exception extends \RuntimeException
{
/**
* Exception types
* @brief Cannot open the file
*/
const CANNOT_OPEN = 1;
/**
* @brief File does not exist
*/
const DOES_NOT_EXIST = 2;
/**
* @brief Cannot write the file
*/
const CANNOT_WRITE = 3;
/**
* @brief Cannot copy the file
*/
const CANNOT_COPY = 4;
/**
* @brief Cannot move the file
*/
const CANNOT_MOVE = 5;
/**
* @brief Cannot create a directory
*/
const CANNOT_MAKE_DIR = 6;
/**
* @brief Region is missing (AWS)
*/
const MISSING_REGION = 7;
/**
@@ -38,28 +62,63 @@ class _Exception extends \RuntimeException
*/
public $file = NULL;
/**
* @brief Original filename (used for friendlier errors)
*/
public $originalFilename = NULL;
/**
* @brief Additional error information
*/
public $errorMessage = NULL;
/**
* @brief Additional log information
*/
public $extraLog = NULL;
/**
* Constructor
*
* @param string $file File path
* @param int $error One of the defined exception constants
* @param string $file File path
* @param int $error One of the defined exception constants
* @param string|null $originalFilename The original filename (used for friendlier error messages)
* @param string|null $errorMessage Error message language string
* @param string|null $extraLog Error information to log
* @return void
*/
public function __construct( $file, $error )
public function __construct( $file, $error, $originalFilename = NULL, $errorMessage = NULL, $extraLog = NULL )
{
/* Store the file */
$this->file = $file;
$this->originalFilename = $originalFilename;
/* We use a prettier error message if we have a dispatcher instance */
if( \IPS\Dispatcher::hasInstance() )
{
$message = sprintf( \IPS\Member::loggedIn()->language()->get( 'files-' . $error ), $file );
}
else
{
$message = array_flip( ( new \ReflectionClass( __CLASS__ ) )->getConstants() )[ $error ];
}
/* Store additional debug info */
$this->errorMessage = $errorMessage;
$this->extraLog = $extraLog;
$message = array_flip( ( new \ReflectionClass( __CLASS__ ) )->getConstants() )[ $error ];
parent::__construct( $message, $error );
}
/**
* Additional error message info
*
* @return string
*/
public function extraErrorMessage()
{
return (string) $this->errorMessage;
}
/**
* Additional log data?
*
* @return string
*/
public function extraLogData()
{
return (string) $this->extraLog;
}
}