Use PHPs `trigger_error` function to trigger all internally stored
errors if error reporting is enabled for $this. The error handler will
be temporarily set to {@see errorHandler} while errors are dispatched via
`trigger_error`.

@return void
509887
private function reportErrors()
    {
        if ( ! $this->errorReporting)
        {
            return;
        }

        set_error_handler([get_class(), 'errorHandler']);

        if ( ! empty($this->errors))
        {
            $this->isBufferReturned = true;
        }

        foreach ($this->errors as $error)
        {
            trigger_error($error->getMessage(), $error->getLevel());
        }

        restore_error_handler();
    }
172272
public function actionError()
	{
		if($error=Yii::app()->errorHandler->error)
		{
			if(Yii::app()->request->isAjaxRequest)
				echo $error['message'];
			else
				$this->render('error', $error);
		}
	}
748180
private function setErrorReporting()
    {
        // set error reporting
        $errorReporting = $this->applicationConfig->get('Application.Environments.' . $this->getCurrentEnvironmentName(
                     ) . '.ErrorReporting', 'off'
        );
        if (strtolower($errorReporting) == 'on') {
            error_reporting(E_ALL);
        } else {
            error_reporting(E_ALL);
        }
    }
1156653
public function __triggerError($functionname, $error)
	{
		if($error == false) {
			trigger_error(sprintf("SimpleEmailService::%s(): Encountered an error, but no description given", $functionname), E_USER_WARNING);
		}
		else if(isset($error['curl']) && $error['curl'])
		{
			trigger_error(sprintf("SimpleEmailService::%s(): %s %s", $functionname, $error['code'], $error['message']), E_USER_WARNING);
		}
		else if(isset($error['Error']))
		{
			$e = $error['Error'];
			$message = sprintf("SimpleEmailService::%s(): %s - %s: %s\nRequest Id: %s\n", $functionname, $e['Type'], $e['Code'], $e['Message'], $error['RequestId']);
			trigger_error($message, E_USER_WARNING);
		}
		else {
			trigger_error(sprintf("SimpleEmailService::%s(): Encountered an error: %s", $functionname, $error), E_USER_WARNING);
		}
	}
314531
public function setErrorReporting() {
        if (true ===  $this->_config->getConfigData('development_environment')) {
            error_reporting(E_ALL);
            ini_set('display_errors', 'On');

            ErrorHandler::register();
        } else {
            error_reporting(E_ALL);
            ini_set('display_errors', 'Off');
            ini_set('log_errors', 'On');
            ini_set('error_log', ROOT . DS . 'tmp' . DS . 'logs' . DS . 'error.log');
        }
    }
157496
protected function activateWarningLogger()
    {
        $this->previousErrorHandler = set_error_handler(
            array($this, "warningHandler"),
            E_WARNING | E_USER_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_ERROR
        );
    }
817871
public function log_php_errors( $error_types = NULL ) {

		static $done = FALSE;
		if ( $done ) {
			return $this;
		}

		$done = TRUE;
		is_int( $error_types ) or $error_types = E_ALL | E_STRICT;

		$controller = new PhpErrorController();
		register_shutdown_function( [ $controller, 'on_fatal', ] );
		set_error_handler( [ $controller, 'on_error' ], $error_types );
		set_exception_handler( [ $controller, 'on_exception', ] );

		// Ensure that channel Channels::PHP_ERROR error is there
		add_filter(
			Channels::FILTER_CHANNELS,
			function ( array $channels ) {

				$channels[] = Channels::PHP_ERROR;

				return $channels;
			},
			PHP_INT_MAX
		);

		return $this;
	}
193713
protected function triggerError($msg, $no)
    {
        // determine previous stack frame
        $extra = '';
        if ($this->chatty) {
            $trace = debug_backtrace();
            // zip(tail(trace), trace) -- but PHP is not Haskell har har
            for ($i = 0, $c = count($trace); $i < $c - 1; $i++) {
                // XXX this is not correct on some versions of HTML Purifier
                if ($trace[$i + 1]['class'] === 'HTMLPurifier_Config') {
                    continue;
                }
                $frame = $trace[$i];
                $extra = " invoked on line {$frame['line']} in file {$frame['file']}";
                break;
            }
        }
        trigger_error($msg . $extra, $no);
    }
1035393
private function triggerSocketError()
	{
		$errorNo = \socket_last_error( $this->resource );
		$errorStr = \socket_strerror( $errorNo );
		\trigger_error( '\\Kshabazz\\Interception\\StreamWrappers\\Http ' . $errorStr );
	}
277636
static function error2exception()
    {
        set_error_handler(
            function ($errno, $errstr, $errfile, $errline) {
                $r = error_reporting();
                if ($r & $errno) {
                    $exception = new \ErrorException($errstr, null, $errno,
                        $errfile, $errline);
                    if ($errno == E_USER_ERROR || $errno == E_RECOVERABLE_ERROR) {
                        throw $exception;
                    }
                    static::catchException($exception);
                }
            });
    }
205779
private function phpExceptionHandler(): Closure
    {
        return static function (Throwable $ex): void {
            $base_path = dirname(__DIR__);
            $trace     = $ex->getMessage() . PHP_EOL . $ex->getTraceAsString();
            $trace     = str_replace($base_path, '…', $trace);

            while (ob_get_level() > 0) {
                ob_end_clean();
            }

            echo '<html lang="en"><head><title>Error</title><meta charset="UTF-8"></head><body><pre>' . $trace . '</pre></body></html>';
        };
    }
418724
public function OnUncaughtErrorTriggered($errSeverity, $errMessage, $errFile, $errLine, array $errContext)
    {
        //@call
        if (0 === error_reporting()) {
            return false;
        }
        throw new PHPTriggerErrorException($errMessage, $errLine, $errFile, $errSeverity);
    }
964013
public static function set(): ?callable
    {
        if (! static::$handler) {
            static::$handler = function ($severity, $message, $file, $line): void {
                throw new \ErrorException($message, 0, $severity, $file, $line);
            };
        }

        return set_error_handler(static::$handler, E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);
    }
1275318
protected function jobErrorContext()
    {
        if (!Mage::getStoreConfigFlag('system/cron/enableErrorLog')) {
            return;
        }

        $settings = array(
            'error_reporting' => intval(Mage::getStoreConfig('system/cron/errorLevel')),
            'log_errors' => true,
            'display_errors' => true,
            'error_log' => $this->getErrorLogFile()
        );

        restore_error_handler();
        // (doesn't work for PHP 5.3) set_error_handler(null); // switch to PHP default error handling

        if (!is_dir(dirname($settings['error_log']))) {
            mkdir(dirname($settings['error_log']), 0775, true);
        }

        foreach ($settings as $key => $value) {
            // backup original settings first
            $this->errorSettingsBackup[$key] = ini_get($key);
            // set new value
            ini_set($key, $value);
        }
    }
995991
private function setErrorData()
    {
        if (!isset($this->record['context']['error'])) {
            return;
        }

        $this->errorData = $this->record['context']['error'];

        // remove the error from the context so we can use it for for other things.
        unset($this->record['context']['error']);
    }
590497
static function handleError($errstr, $type = E_USER_ERROR)
    {
        self::set("errors", true);

        trigger_error($errstr, $type);
    }
136068
static public function catchFatal()
    {
        $error = error_get_last();
        if ($error["type"] == E_ERROR 
            || $error['type'] == E_PARSE 
            || $error['type'] == E_CORE_ERROR
            || $error['type'] == E_COMPILE_ERROR) {
            self::errorHandler($error["type"], $error["message"], $error["file"], $error["line"]);
            /**
              Put fatals in the error log as well as the debug log
              For good measure, put them in STDERR too. Try to
              ensure somebody notices.
            */
            $msg = $error['message']
                . ' Line ' . $error['line']
                . ', File ' . $error['file'];
            self::$logger->error($msg);
            file_put_contents('php://stderr', $msg, FILE_APPEND);
        }
    }