Framework: Illuminate\Database\QueryException

Created on 26 Jul 2015  ·  3Comments  ·  Source: laravel/framework

Preconditions

I am packaging an app called Paperwork which has been created with the Laravel Framework for a platform called Sandstorm. I first have build the package with Docker and now switched to Vagrant for that. I have a problem migrating old instances of the package which have been created with Docker to the new version.

Issue related to the Laravel Framework

At one point an error from the Laravel Framework is shown which indicates an issue with the MySQL connection or the database elsewhere but instead of showing a helpful SQL error a "Class not found" error is shown.

How to reproduce the issue

Take an existing app with database and rename a random used table to something else.

Expected behavior

The raised error should show a message like "table xyz not found" or something else helpful should be shown, like "advertised" in the code:

// If an exception occurs when attempting to run a query, we'll format the error
// message to include the bindings with SQL, which will make this exception a
// lot more helpful to the developer instead of just the database's errors.

Current behavior

The following message appears which doesn't help to track down the root cause:

 /opt/app/frontend/vendor/laravel/framework/src/Illuminate/Database/Connection.php 
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_UNKNOWN)
Class 'Illuminate\Database\QueryException' not found
        }

        // If an exception occurs when attempting to run a query, we'll format the error
        // message to include the bindings with SQL, which will make this exception a
        // lot more helpful to the developer instead of just the database's errors.
        catch (\Exception $e)
        {
            throw new QueryException(
                $query, $this->prepareBindings($bindings), $e
            );

I guess that the class QueryException is a component of the Laravel Framework which has been changed or doesn't work as expected.

Can you please help me with that? Am I guessing right or is the cause of the not so good fatal error exception not based in the Laravel Framework?

FYI: a screen shot of the error message:
bildschirmfoto 2015-07-26 um 16 18 09

Most helpful comment

FYI, if anybody else has an older version of the framwork and gets an issue:

Add in paperwork/frontend/vendor/laravel/framework/src/Illuminate/Database/Connection.php this line at the beginning:

use Illuminate\Database\QueryException;

bildschirmfoto 2015-07-28 um 13 44 03

After having done that you get a proper error message and can start debugging.

All 3 comments

Laravel 4.2 is not supported, sorry.

It would be nice to have at least a useful hint like "upgrade to the latest framework". A "We are not helping" response is pretty lame.

FYI, if anybody else has an older version of the framwork and gets an issue:

Add in paperwork/frontend/vendor/laravel/framework/src/Illuminate/Database/Connection.php this line at the beginning:

use Illuminate\Database\QueryException;

bildschirmfoto 2015-07-28 um 13 44 03

After having done that you get a proper error message and can start debugging.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

klimentLambevski picture klimentLambevski  ·  3Comments

YannPl picture YannPl  ·  3Comments

ghost picture ghost  ·  3Comments

gabriellimo picture gabriellimo  ·  3Comments

kerbylav picture kerbylav  ·  3Comments