You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB
PHTML

<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Util;
/**
13 years ago
* Convert PHP errors into exceptions
*
* @author Artem Lopata <biozshock@gmail.com>
*/
class ErrorHandler
{
/**
* Error handler
*
13 years ago
* @param int $level Level of the error raised
* @param string $message Error message
* @param string $file Filename that the error was raised in
* @param int $line Line number the error was raised at
*
* @static
* @throws \ErrorException
*/
13 years ago
public static function handle($level, $message, $file, $line)
{
13 years ago
// respect error_reporting being disabled
if (!error_reporting()) {
return;
}
13 years ago
throw new \ErrorException($message, 0, $level, $file, $line);
}
/**
13 years ago
* Register error handler
*
* @static
*/
13 years ago
public static function register()
{
set_error_handler(array(__CLASS__, 'handle'));
}
}