doutao1171 2016-03-14 20:32
浏览 208

neo4j-php-client中的错误处理程序

I downloaded and installed neo4j-php-client and neo4j 2.3.2. Actually all works fine, but I just wondering why there is no error handlers in this php client? For example if there is an error in cypher query, no error has throwing to be easy to catch it. I searching through the network, but I can't found a solution.

Do anybody have an idea how to turn on error handlers?

Thanks in advance.

  • 写回答

2条回答 默认 最新

  • duande3134 2016-03-14 20:44
    关注

    I'm the maintainer of neo4j-php-client.

    When you send a query to Neo4j, it is actually sent via Guzzle.

    Of course there is a try/catch block for handling exceptions, which is located here :

    https://github.com/graphaware/neo4j-php-client/blob/master/src/HttpClient/GuzzleHttpClient.php#L76

    If there is an error in your cypher query, an exception will be thrown of course, the exception is of type Neo4jException (https://github.com/graphaware/neo4j-php-client/blob/master/src/Exception/Neo4jException.php)

    Here is a simple code with a cypher syntax error and you can see an exception is thrown :

    <?php
    
    require_once __DIR__ .'/vendor/autoload.php';
    
    use Neoxygen\NeoClient\ClientBuilder;
    
    $client = ClientBuilder::create()
        ->addConnection('default', 'http', 'localhost', 7474)
        ->setAutoFormatResponse(true)
        ->build();
    
    $query = 'MATCH (n) RETURN x';
    
    $result = $client->sendCypherQuery($query)->getResult();
    

    -

    ikwattro@graphaware ~/d/g/p/neo4j-php-client> php test.php
    PHP Fatal error:  Uncaught Neoxygen\NeoClient\Exception\Neo4jException: Neo4j Exception with code "Neo.ClientError.Statement.InvalidSyntax" and message "Variable `x` not defined (line 1, column 18 (offset: 17))
    "MATCH (n) RETURN x"
                      ^" in /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/AbstractExtension.php:117
    Stack trace:
    #0 /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/AbstractExtension.php(104): Neoxygen\NeoClient\Extension\AbstractExtension->checkResponseErrors(Array)
    #1 /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/NeoClientCoreExtension.php(98): Neoxygen\NeoClient\Extension\AbstractExtension->handleHttpResponse(Object(Neoxygen\NeoClient\Request\Response))
    #2 [internal function]: Neoxygen\NeoClient\Extension\NeoClientCoreExtension->sendCypherQuery('MATCH (n) RETUR...')
    #3 /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/ExtensionManager.php(53): call_user_func_array(Array, Array)
    #4 /Users/ikwattro/dev/graphaware/php/neo4j-php-cli in /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/AbstractExtension.php on line 117
    
    Fatal error: Uncaught Neoxygen\NeoClient\Exception\Neo4jException: Neo4j Exception with code "Neo.ClientError.Statement.InvalidSyntax" and message "Variable `x` not defined (line 1, column 18 (offset: 17))
    "MATCH (n) RETURN x"
                      ^" in /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/AbstractExtension.php:117
    Stack trace:
    #0 /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/AbstractExtension.php(104): Neoxygen\NeoClient\Extension\AbstractExtension->checkResponseErrors(Array)
    #1 /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/NeoClientCoreExtension.php(98): Neoxygen\NeoClient\Extension\AbstractExtension->handleHttpResponse(Object(Neoxygen\NeoClient\Request\Response))
    #2 [internal function]: Neoxygen\NeoClient\Extension\NeoClientCoreExtension->sendCypherQuery('MATCH (n) RETUR...')
    #3 /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/ExtensionManager.php(53): call_user_func_array(Array, Array)
    #4 /Users/ikwattro/dev/graphaware/php/neo4j-php-cli in /Users/ikwattro/dev/graphaware/php/neo4j-php-client/src/Extension/AbstractExtension.php on line 117
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog