Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print nice errors to the screen #362

Closed
wants to merge 3 commits into from
Closed

Print nice errors to the screen #362

wants to merge 3 commits into from

Conversation

whikloj
Copy link
Member

@whikloj whikloj commented Apr 23, 2019

JIRA Ticket: https://jira.duraspace.org/browse/ISLANDORA-2419

What does this Pull Request do?

Captures the Exception thrown from SolrPhpClient and logs it to watchdog instead of printing it to the screen. Then it presents a simple text message.

What's new?

There is a variable in the SolrPhpClient set based on the response from Solr, if Solr is shut down this displays a NOTICE. So I silenced that. Made a small function to help aggregate multiple error messages into a single message on screen and in the log. Also removed some extraneous try {} catch blocks (which I didn't realize where useless as the Exception was caught in the query_processor)

How should this be tested?

Turn off your Solr and use Islandora, go to Search pages, etc.
See the large red Exception text.
Pull in this PR.
See the nice yellow warning text, check your log for the Exception text.

Additional Notes:

Example:

  • Does this change the interface, add a new feature, or otherwise change behaviours that would require updating documentation? unsure
  • Does this change add any new dependencies? no
  • Does this change require any other modifications to be made to the repository (ie. Regeneration activity, etc.)? no
  • Could this change impact execution of existing code? no

Interested parties

@Islandora/7-x-1-x-committers

// Islandora: dump solr query address in debug mode
if (variable_get('islandora_solr_debug_mode', 0) && user_access('view islandora solr debug')) {
drupal_set_message(l('solr query',$url."&indent=on&debugQuery=true"));
}
//$http_response_header is set by file_get_contents
$response = new Apache_Solr_Response(@file_get_contents($url, false, $this->_getContext), $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays);
$response = new Apache_Solr_Response(@file_get_contents($url, false, $this->_getContext), @$http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wuhu! so you are editing the Client =) This opens a lot of possibilities ++

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't going to, but then I saw that islandora_solr_debug_mode block above. Also I have given up replacing this client, easier to fix it in Islandora 8.

@@ -399,7 +399,7 @@ class IslandoraSolrQueryProcessor {
$results = $solr->search($solr_query, $this->solrStart, $this->solrLimit, $this->solrParams, $method);
}
catch (Exception $e) {
drupal_set_message(check_plain(t('Error searching Solr index')) . ' ' . $e->getMessage(), 'error');
islandora_solr_technical_difficulties($e);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this name.. we need a hook named the same way (kidding)

if ($islandora_solr_error_reported !== true) {
$message = "We are experiencing technical difficulties at this time and are working to fix the problem. Please try back later.";
drupal_set_message(t($message), 'warning');
watchdog("manidora", "Received exception @code: @message\nLine: @line in file: @file", array(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manidora?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DOH!

Copy link

@DiegoPino DiegoPino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the manidora piece. Rest looks good


if ($islandora_solr_error_reported !== true) {
if ($islandora_solr_error_reported !== TRUE) {
$message = "We are experiencing technical difficulties at this time and are working to fix the problem. Please try back later.";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final request. Could we have a way of customizing this message? Since it's front facing.. i know i know we did not have it before so why now? Because people i know will ask for it for sure.. maybe a hook-ie? i mean, its not a blocker... since you can always disable reporting at all...but could be cool? sorry

Copy link

@DiegoPino DiegoPino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. What better reason to catch exceptions than actually letting them to be thrown! Good, good.

@whikloj
Copy link
Member Author

whikloj commented Apr 23, 2019

PHP 5.3.3 holding on to the buggy so your electric car moves very slowly.

@DiegoPino
Copy link

Restarting the test, error is of type "HttpConnectionException' with message" so not DCS... i guess

@whikloj
Copy link
Member Author

whikloj commented Apr 23, 2019

@DiegoPino I've restarted it a couple times and it always seems to fail when setting up Islandora/Fedora

@DiegoPino
Copy link

If i was release manager i would say lets merge this anyway in 24 hours. I'm a bit done with travis....

@jonathangreen
Copy link

php 5 3 3

@whikloj
Copy link
Member Author

whikloj commented Apr 23, 2019

Perhaps (😬) it is time (again) to consider shifting PHP 5.3.3 to an allowed failure.

@DiegoPino
Copy link

So.. seems still failing. Should i merge???

@whikloj
Copy link
Member Author

whikloj commented Apr 24, 2019

@DiegoPino this is on the agenda for a TAG meeting on Friday, why don't we hold off until then.

@whikloj
Copy link
Member Author

whikloj commented Apr 30, 2019

Closing in favour of #363

@whikloj whikloj closed this Apr 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants