beyondcode / invoker-community

74 stars 2 forks source link

Error for Parent model that doesnt have a table associated. #297

Closed tobya closed 1 year ago

tobya commented 2 years ago

I have a parent model BCSModels that some of my models inherit from that adds some functionality to all models. There is no table associated and I dont create instances of it. I click on it and go this error. Its fine because it shouldnt work, but perhpas could say 'Table for this model does not exist' or a nicer error message.

OS: win32 Invoker Version: 2.9.0 Laravel Version: 8.83.16 Local project: true PHP Binary: /usr/local/bin/php Route: /project/index?class=App%5CModels%5CBCSModel&time=1656485425206&project=local-rDcKHFoxoYoqC6bazEjufW

Error:

Illuminate\Database\QueryException 

  SQLSTATE[42S02]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'b_c_s_models'. (SQL: select top 1 * from [b_c_s_models])

  at C:\Development\github\bcsStudents_gitp4\vendor\laravel\framework\src\Illuminate\Database\Connection.php:712
    708▕         // If an exception occurs when attempting to run a query, we'll format the error
    709▕         // message to include the bindings with SQL, which will make this exception a
    710▕         // lot more helpful to the developer instead of just the database's errors.
    711▕         catch (Exception $e) {
  ➜ 712▕             throw new QueryException(
    713▕                 $query, $this->prepareBindings($bindings), $e
    714▕             );
    715▕         }
    716▕     }

  • A table was not found: You might have forgotten to run your migrations. You can run your migrations using `php artisan migrate`. 
    https://laravel.com/docs/master/migrations#running-migrations

      +4 vendor frames 
  5   C:\Development\github\bcsStudents_gitp4\vendor\laravel\framework\src\Illuminate\Database\Connection.php:373
      Doctrine\DBAL\Driver\PDOStatement::execute()

  6   C:\Development\github\bcsStudents_gitp4\vendor\laravel\framework\src\Illuminate\Database\Connection.php:705
      Illuminate\Database\Connection::Illuminate\Database\{closure}("select top 1 * from [b_c_s_models]", [])
mpociot commented 1 year ago

As we catch all query exceptions and show them in the UI, there's no easy way to handle the table not found error differently.