tbolier / php-rethink-ql

Brand new PHP RethinkDB driver for RethinkDB >= 2.3.0 for any framework or application
Apache License 2.0
53 stars 18 forks source link

Runtime error if user has no rights granted #78

Open tbolier opened 5 years ago

tbolier commented 5 years ago

To test I'm now using this code:

$r = new Rethink($registry->getConnection('default'));
$r->connection()->connect();
$r->db()
  ->tableCreate('test')
  ->run();

I'm getting a Runtime Error:

PHP Fatal error:  Uncaught TBolier\RethinkQL\Connection\ConnectionException: Runtime error: U, jsonQuery: [1,[60,[[1,"test"]]],{"db":[14,["vagrant"]]}] in/code/vendor/tbolier/php-rethink-ql/src/Connection/Connection.php:372
Stack trace:
#0 /code/vendor/tbolier/php-rethink-ql/src/Connection/Connection.php(334): TBolier\RethinkQL\Connection\Connection->validateResponse(Object(TBolier\RethinkQL\Response\Response), 820726866, 820726866, Object(TBolier\RethinkQL\Message\Message))
#1 /code/vendor/tbolier/php-rethink-ql/src/Connection/Connection.php(169): TBolier\RethinkQL\Connection\Connection->receiveResponse(820726866, Object(TBolier\RethinkQL\Message\Message))
#2 /code/vendor/tbolier/php-rethink-ql/src/Query/AbstractQuery.php(32): TBolier\RethinkQL\Connection\Connection->run(Object(TBolier\RethinkQL\Message\Message))
#3 /code/bin/OrderBook.php(28): TBolier\RethinkQL\Query\AbstractQuery->run()
#4 {main}

Next TBolier\RethinkQL\Connection\ConnectionException: Runtime error: U, jsonQuery: [1,[60,[[1,"test"]]],{"db":[14,["vagrant"]] in /code/vendor/tbolier/php-rethink-ql/src/Connection/Connection.php on line 181

This is because I did not grant the permissions to the user yet. Might need a different error message.

Originally posted by @mpjraaij in https://github.com/tbolier/php-rethink-ql/issues/76#issuecomment-440288342

tbolier commented 5 years ago

Hi @mpjraaij

Thanks for reporting this one. Right now any RethinkDB error is passed back directly to the client. There is no interpreter in between that generates a friendly error for the client. I will need to think about a good solution for this.