tarantool-php / client

PHP client for Tarantool.
MIT License
67 stars 22 forks source link

Non informative trace log of Exceptions #81

Closed PavelFil closed 1 year ago

PavelFil commented 1 year ago

Exceptions doesn't display full trace. It's hard to understand which code throws the exception.

Try to run:

require_once __DIR__.'/vendor/autoload.php';
$client = \Tarantool\Client\Client::fromOptions([
    'uri' => 'tcp://127.0.0.1:3301',
    'username' => 'admin',
    'password' => 'pass'
]);

$client->evaluate("box.schema.space.create('test')");
$client->evaluate("box.space.test:format({
        {name = 'hash', type = 'string'}
    })");
$client->evaluate("box.space.test:create_index('primary', {
         type = 'hash',
         parts = {'hash'}
    })");
$space = $client->getSpace('test');
$space->insert(['info']);
$space->insert(['info']);

You will receive:

PHP Fatal error:  Uncaught Tarantool\Client\Exception\RequestFailed: Duplicate key exists in unique index "primary" in space "test" with old tuple - ["info"] and new tuple - ["info"] in /var/www/vendor/tarantool/client/src/Exception/RequestFailed.php:32
Stack trace:
#0 /var/www/vendor/tarantool/client/src/Handler/DefaultHandler.php(48): Tarantool\Client\Exception\RequestFailed::fromErrorResponse(Object(Tarantool\Client\Response))
#1 /var/www/vendor/tarantool/client/src/Handler/MiddlewareHandler.php(76): Tarantool\Client\Handler\DefaultHandler->handle(Object(Tarantool\Client\Request\InsertRequest))
#2 /var/www/vendor/tarantool/client/src/Middleware/AuthenticationMiddleware.php(41): Tarantool\Client\Handler\MiddlewareHandler->handle(Object(Tarantool\Client\Request\InsertRequest))
#3 /var/www/vendor/tarantool/client/src/Handler/MiddlewareHandler.php(82): Tarantool\Client\Middleware\AuthenticationMiddleware->process(Object(Tarantool\Client\Request\InsertRequest), Object(Tarantool\Client\Handler\M in /var/www/vendor/tarantool/client/src/Exception/RequestFailed.php on line 32

There is no information about the row $space->insert(['info']); which causes the error. I wanna see full trace log in debug message.

rybakit commented 1 year ago

What OS, PHP and client version do you use? I cannot reproduce the problem with PHP 8.1.2 and tarantool/client v0.10.0, on my environment your example script outputs a full trace, including the initial line that caused the error:

PHP Fatal error:  Uncaught Tarantool\Client\Exception\RequestFailed: Duplicate key exists in unique index "primary" in space "test" with old tuple - ["info"] and new tuple - ["info"] in .../tarantool-php/client/src/Exception/RequestFailed.php:32
Stack trace:
#0 .../tarantool-php/client/src/Handler/DefaultHandler.php(48): Tarantool\Client\Exception\RequestFailed::fromErrorResponse()
#1 .../tarantool-php/client/src/Handler/MiddlewareHandler.php(76): Tarantool\Client\Handler\DefaultHandler->handle()
#2 .../tarantool-php/client/src/Middleware/AuthenticationMiddleware.php(41): Tarantool\Client\Handler\MiddlewareHandler->handle()
#3 .../tarantool-php/client/src/Handler/MiddlewareHandler.php(82): Tarantool\Client\Middleware\AuthenticationMiddleware->process()
#4 .../tarantool-php/client/src/Schema/Space.php(77): Tarantool\Client\Handler\MiddlewareHandler->handle()
#5 .../tarantool-php/client/test.php(21): Tarantool\Client\Schema\Space->insert()
#6 {main}
  thrown in .../tarantool-php/client/src/Exception/RequestFailed.php on line 32

It looks like your error output is cut off, I don't see {main} in your version.

PavelFil commented 1 year ago

I tested on PHP v7.4.3. But after update to 8.1.13 I see the same trace log. I think we can close the issue.