public static function handleError($query = '', $queryLog = false, $errorHandler = null)
    {
        if (is_callable($errorHandler, false, $callable)) {
            return call_user_func($errorHandler, $query, $queryLog);
        }

        // save queryLog
        if ($queryLog) {
            $error = static::getConnection()->errorInfo();
            $queryLog['error'] = $error[2];
            static::finishQueryLog($queryLog);
        }

        // get error message
        $error = static::getConnection()->errorInfo();
        $message = $error[2];

        if (App::$Config['environment']=='dev') {
            $Handler = \Divergence\App::$whoops->popHandler();

            $Handler->addDataTable("Query Information", [
                'Query'     	=>	$query,
                'Error'		=>	$message,
                'ErrorCode'	=>	static::getConnection()->errorCode(),
            ]);

            \Divergence\App::$whoops->pushHandler($Handler);

            throw new \RuntimeException("Database error!");
        } else {
            throw new \RuntimeException("Database error!");
        }
    }
public static function handleError($query = '', $queryLog = false, $errorHandler = null)
    {
        if (is_callable($errorHandler, false, $callable)) {
            return call_user_func($errorHandler, $query, $queryLog);
        }

        // save queryLog
        if ($queryLog) {
            $error = static::getConnection()->errorInfo();
            $queryLog['error'] = $error[2];
            static::finishQueryLog($queryLog);
        }

        // get error message
        $error = static::getConnection()->errorInfo();
        $message = $error[2];

        if (App::$Config['environment']=='dev') {
            $Handler = \Divergence\App::$whoops->popHandler();

            $Handler->addDataTable("Query Information", [
                'Query'     	=>	$query,
                'Error'		=>	$message,
                'ErrorCode'	=>	static::getConnection()->errorCode(),
            ]);

            \Divergence\App::$whoops->pushHandler($Handler);

            throw new \RuntimeException("Database error!");
        } else {
            throw new \RuntimeException("Database error!");
        }
    }
public static function handleError ( $ query = '' , $ queryLog = false , $ errorHandler = null ) { if ( is_callable ( $ errorHandler , false , $ callable ) ) { return call_user_func ( $ errorHandler , $ query , $ queryLog ) ; } // save queryLog if ( $ queryLog ) { $ error = static :: getConnection ( ) -> errorInfo ( ) ; $ queryLog [ 'error' ] = $ error [ 2 ] ; static :: finishQueryLog ( $ queryLog ) ; } // get error message $ error = static :: getConnection ( ) -> errorInfo ( ) ; $ message = $ error [ 2 ] ; if ( App :: $ Config [ 'environment' ] == 'dev' ) { $ Handler = \ Divergence \ App :: $ whoops -> popHandler ( ) ; $ Handler -> addDataTable ( "Query Information" , [ 'Query' => $ query , 'Error' => $ message , 'ErrorCode' => static :: getConnection ( ) -> errorCode ( ) , ] ) ; \ Divergence \ App :: $ whoops -> pushHandler ( $ Handler ) ; throw new \ RuntimeException ( "Database error!" ) ; } else { throw new \ RuntimeException ( "Database error!" ) ; } }
Handles any errors that are thrown by PDO

If App::$Config['environment'] is 'dev' this method will attempt to hook into whoops and provide it with information about this query.

@throws \RuntimeException Database error!

@param string $query The query which caused the error.
@param boolean|array $queryLog An array created by startQueryLog containing logging information about this query.
@param callable $errorHandler An array handler to use instead of this one. If you pass this in it will run first and return directly.
@return void|mixed If $errorHandler is set to a callable it will try to run it and return anything that it returns. Otherwise void
Handles any errors that are thrown by PDO