public static function errToException($turnOn = true)
    {
        if (!$turnOn) {
            return set_error_handler(null);
        }

        /*
         * Error handler
         *
         * @param int $errno
         * @param string $errStr
         * @param string $errFile
         * @param int $errLine
         *
         * @throws ErrorException
         */
        $handler = function ($errno, $errStr, $errFile, $errLine) {
            // This error code is not included in error_reporting
            if (!(error_reporting() & $errno)) {
                return;
            }
            throw new ErrorException($errStr, 0, $errno, $errFile, $errLine);
        };

        return set_error_handler($handler);
    }