public static function errorToException($errno, $errstr, $errfile, $errline)
    {
        $exclude = E_STRICT | E_NOTICE | E_USER_NOTICE;
        if (((error_reporting() & $errno) != $errno) || (($exclude & $errno) == $errno)) {
            return false;
        }

        $constants = get_defined_constants(true);
        $name = 'Unknown PHP Error (' . $errno . ')';
        foreach ($constants['Core'] as $c => $value) {
            if ((substr($c, 0, 2) != 'E_') || ($value != $errno)) {
                continue;
            }

            $name = 'PHP ' . ucwords(str_replace('_', ' ', strtolower(substr($c, 2))));
        }

        $exception = new \RuntimeException(sprintf('%s: %s in %s on line %d', $name, $errstr, $errfile, $errline), $errno);

        // Impossible to throw an exception without stack trace
        // happens when errors occour in shutdown scope (i.e. serialize handler)
        if (count($exception->getTrace()) < 1) {
            return false;
        }

        throw $exception;
    }