* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ /** * @since 1.5.0 */ class PrestaShopExceptionCore extends Exception { /** * This method acts like an error handler, if dev mode is on, display the error else use a better silent way. */ public function displayMessage() { if (getenv('kernel.environment') === 'test') { throw $this; } header('HTTP/1.1 500 Internal Server Error'); if (ToolsCore::isPHPCLI()) { echo get_class($this) . ' in ' . $this->getFile() . ' line ' . $this->getLine() . "\n"; echo $this->getTraceAsString() . "\n"; } elseif (_PS_MODE_DEV_) { // Display error message echo ''; echo '
';
foreach ($lines as $k => $l) {
$string = ($offset + $k) . '. ' . htmlspecialchars($l);
if ($offset + $k == $line) {
echo '' . $string . '';
} else {
echo $string;
}
}
echo '';
foreach ($args as $arg => $value) {
echo 'Argument [' . Tools::safeOutput($arg) . "]\n";
echo Tools::safeOutput(print_r($value, true));
echo "\n";
}
echo '';
}
/**
* Log the error on the disk.
*/
protected function logError()
{
$logger = new FileLogger();
$logger->setFilename(_PS_ROOT_DIR_ . '/var/logs/' . date('Ymd') . '_exception.log');
$logger->logError($this->getExtendedMessage(false));
}
/**
* Return the content of the Exception.
*
* @return string content of the exception
*/
protected function getExtendedMessage($html = true)
{
$format = '%s
at line %d in file %s