</code>Steps to replicate:
Use case 1:
1. Make sure Solr server is *unreachable*
2. Create a Solr server + index
Expected: Error validating server connection
Actual output: WSOD
Use case 2:
1. Make sure Solr server is *reachable*
2. Create Solr server + index
3. Close Solr
4. Visit index page
Expected: Index page with error message
Actual output: WSOD
<code>
The website encountered an unexpected error. Please try again later.
Solarium\Exception\HttpException: Solr HTTP error: HTTP request failed, Failed to connect to localhost port 8983: Connection refused in Solarium\Core\Client\Adapter\Curl->check() (line 248 of modules/search_api_solr/vendor/solarium/solarium/library/Solarium/Core/Client/Adapter/Curl.php).
Solarium\Core\Client\Adapter\Curl->getResponse(Resource, )
Solarium\Core\Client\Adapter\Curl->getData(Object, Object)
Solarium\Core\Client\Adapter\Curl->execute(Object, Object)
Solarium\Core\Client\Client->executeRequest(Object)
Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend->search(Object)
Drupal\search_api\Entity\Server->search(Object)
theme_search_api_index(Array)
Drupal\Core\Theme\ThemeManager->render('search_api_index', Array)
Drupal\Core\Render\Renderer->doRender(Array)
Drupal\Core\Render\Renderer->doRender(Array, )
Drupal\Core\Render\Renderer->render(Array, )
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}()
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1)
Drupal\devel\StackMiddleware\DevelMiddleware->handle(Object, 1, 1)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1)
Stack\StackedHttpKernel->handle(Object, 1, 1)
Drupal\Core\DrupalKernel->handle(Object)
Estimated Value and Story Points
This issue was identified as a Beta Blocker for Drupal 8. We sat down and figured out the value proposition and amount of work (story points) for this issue.
Value and Story points are in the scale of fibonacci. Our minimum is 1, our maximum is 21. The higher, the more value or work a certain issue has.
Value : 8
Story Points: 2
Comments
Comment #2
cristiroma commentedAttaching a patch which shows server error instead of the count of items from the index.
Comment #4
devd commentedAttached patch is working fine but we have HttpException type object, So it can we catch further.
Comment #5
devd commentedAttached patch is working fine but we have HttpException type object, So it can we catch earlier.
Comment #6
drunken monkeyThanks for reporting this issue and providing a patch!
Two things, though:
First off, it should be
\Exception, according to the Drupal coding standards.More importantly, though, we should more specifically only catch the exception that the code is actually allowed to throw – i.e.,
SearchApiException.That the Solr backend apparently doesn't properly catch its internal exceptions to wrap them in a
SearchApiExceptionobject is a different issue, and should be reported and fixed in that module.In any case, though, catching the possible exception there is correct and very important, so thanks a lot for the patch!
It doesn't have to be a Solr server, this could be any other kind of server (and any other kind of error cause) as well. The message should be much less specific. And probably we should log the exception message somewhere – or, alternately, include it in the displayed information.
Also, we should change
$classto'error'in this case.Comment #7
cristiroma commentedThank you for the comprehensive review!
I have uploaded a patch that addresses your observations, but doesn't solve the problem unless #2577041: Catch internal exceptions and throw them as SearchApiException is also fixed. This would be a first time submiting a non-working patch intentionally :D
Comment #8
cristiroma commented@devd you are trying to catch
Symfony\Component\HttpKernel\Exception\HttpException, while here is thrownSolarium\Exception\HttpException. This is not the same Exception, therefore your first catch statement is ineffective.Comment #9
devd commentedThanks Thomas & Cristian.
Hi Thomas as per you instruction, I did fixed the issued in attached patch.
Hi Cristian, I agree with you but we should the caught the exception at the end in catch block.
Comment #10
drunken monkey@ cristiroma: Thanks for the revised patch, looks better now! However, still some issues:
Please use the import here instead. (Unless I've missed a change in the coding standards?)
This is still too specific. The problem doesn't have to be that the server could not be reached, it's just that an exception occurred during search. Just write that, and then maybe include the exception message to clarify things.
(I.e.,
'Error while checking server index status: @message.')@ devd: Please stop rolling your own patches here, cristiroma's are quite good already, you're just adding confusion. If you want to help, please improve on cristiroma's last patch!
Comment #11
devd commented@Thomas thanks to correct me.
@Cristian thanks to good work.
Comment #12
tlyngej commentedI've updated the patch based on the comments in #10.
Comment #13
tlyngej commentedRight, something went wrong with the other patch. Here's a new one...
Comment #14
nick_vhComment #15
jurcello commentedI reviewed the patch, and I have some remarks:
- There is still a use of \kint in the code.
- Why should the coding style of the header be changed? It is not of importance to this issue I think.
- I find the display of the line number confusing. This adds no information to the error message if the stacktrace is not displayed.
I created a new patch containing the corrections for these remarks.
Comment #16
borisson_We shouldn't translate error messages (see #2055851: Remove translation of exception messages). Use
FormattableMarkupinstead.Comment #17
borisson_My comment in #16 was bogus, this is only when we're throwing exceptions. Patch from #16 is ok.
Comment #18
tlyngej commented@jurcello
- Ups. Didn't notice from the former patch.
- Array exceeded 80 characters, so I re-formatted it, according to the coding standards.
- Agreed, line number doesn't make much sense.
Good job.
Comment #19
borisson_@tlyngej:
Both contrib and core code ask not to include unrelated changes in a patch, especially in unrelated hunks.
Comment #20
drunken monkeyThanks for all your work here!
However, I think you all worked on the wrong patch. As said in #10, I ignored #9, my comments were directed at the patch in #7 (which was already pretty good).
I now just fixed the remaining two small problems myself and committed this.
Still, thanks again!
However, there's also still #2577041: Catch internal exceptions and throw them as SearchApiException which is the real problem here for Solr users.