php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #67063 Introduce SolrServerException to parse and return Solr Server error messages
Submitted: 2014-04-13 13:08 UTC Modified: 2014-06-29 15:21 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: omars@php.net Assigned: omars (profile)
Status: Closed Package: solr (PECL)
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
 [2014-04-13 13:08 UTC] omars@php.net
Description:
------------
When Solr Server returns an error, the SolrClient throws a SolrClientException with message containing the server raw response.

A new SolrServerException class shall be introduced and thrown on Solr Server based exceptions like when Solr Server throws a SolrParseException if the query was malformatted or contains illegal characters.

Solr Client shall parse and throws the exception code and message, instead of throwing a SolrClientException with the raw response

Test script:
---------------
$options = array
(
		'hostname' => SOLR_SERVER_HOSTNAME,
		'login'    => SOLR_SERVER_USERNAME,
		'password' => SOLR_SERVER_PASSWORD,
		'port'     => SOLR_SERVER_PORT,
		'path'	   => SOLR_SERVER_PATH
);

$client = new SolrClient($options);
$query = new SolrQuery("lucene/");

$response = $client->query($query);


Expected result:
----------------
Fatal error: Uncaught exception 'SolrClientException' with message 'SolrServer 400: 'org.apache.lucene.queryparser.classic.ParseException: Cannot parse 'lucene/': Lexical error at line 1, column 8.  Encountered: <EOF> after : ""'

Actual result:
--------------
Fatal error: Uncaught exception 'SolrClientException' with message 'Unsuccessful query request : Response Code 400. <?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
  <int name="status">400</int>
  <int name="QTime">3</int>
  <lst name="params">
    <str name="indent">on</str>
    <str name="wt">xml</str>
    <str name="q">lucene/</str>
    <str name="version">2.2</str>
  </lst>
</lst>
<lst name="error">
  <str name="msg">org.apache.lucene.queryparser.classic.ParseException: Cannot parse 'lucene/': Lexical error at line 1, column 8.  Encountered: &lt;EOF&gt; after : ""</str>
  <int name="code">400</int>
</lst>
</response>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-13 13:10 UTC] omars@php.net
-Assigned To: +Assigned To: omars
 [2014-06-29 15:21 UTC] omars@php.net
-Status: Assigned +Status: Closed
 [2014-06-29 15:21 UTC] omars@php.net
Implemented in 1.1.0, 2.0.0
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 14:01:29 2024 UTC