I am trying to override ErrorHandler class using preference but it is not working. di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Magento\Framework\App\ErrorHandler" type="Pulsestorm\HelloWorldMVVM\Model\ErrorHandler"/>
</config>
ErrorHandler.php
<?php
namespace Pulsestorm\HelloWorldMVVM\Model;
class ErrorHandler extends \Magento\Framework\App\ErrorHandler{
public function getHandler()
{ echo"hii"; exit;
if (strpos($errorStr, 'DateTimeZone::__construct') !== false) {
// there's no way to distinguish between caught system exceptions and warnings
return false;
}
$errorNo = $errorNo & error_reporting();
if ($errorNo == 0) {
return false;
}
$msg = isset($this->errorPhrases[$errorNo]) ? $this->errorPhrases[$errorNo] : "Unknown error ({$errorNo})";
$msg .= ": {$errorStr} in {$errorFile} on line {$errorLine}";
throw new \Exception($msg);
}
}
I used echo exit to check preference is working or not. When any error or exception comes it doesn't echo and exit. Please let me know what I am doing wrong. Thank you in advance.
getHandler
in that class.