-
Notifications
You must be signed in to change notification settings - Fork 93
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
Issuexxxx improve http error handling #1033
Changes from all commits
1fcd308
a1bfbed
4ab7ba3
583b950
af94269
9f762ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,12 +157,19 @@ public function getInfo($lang = null) | |
} | ||
} | ||
|
||
// also include ConceptScheme metadata from SPARQL endpoint | ||
$defaultcs = $this->getDefaultConceptScheme(); | ||
|
||
// query everything the endpoint knows about the ConceptScheme | ||
$sparql = $this->getSparql(); | ||
$result = $sparql->queryConceptScheme($defaultcs); | ||
try { | ||
// also include ConceptScheme metadata from SPARQL endpoint | ||
$defaultcs = $this->getDefaultConceptScheme(); | ||
|
||
// query everything the endpoint knows about the ConceptScheme | ||
$sparql = $this->getSparql(); | ||
$result = $sparql->queryConceptScheme($defaultcs); | ||
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { | ||
if ($this->model->getConfig()->getLogCaughtExceptions()) { | ||
error_log('Caught exception: ' . $e->getMessage()); | ||
} | ||
return null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this ok? |
||
} | ||
$conceptscheme = $result->resource($defaultcs); | ||
$this->order = array("dc:title", "dc11:title", "skos:prefLabel", "rdfs:label", "dc:subject", "dc11:subject", "dc:description", "dc11:description", "dc:publisher", "dc11:publisher", "dc:creator", "dc11:creator", "dc:contributor", "dc:language", "dc11:language", "owl:versionInfo", "dc:source", "dc11:source"); | ||
|
||
|
@@ -227,8 +234,15 @@ public function getConceptSchemes($lang = '') | |
if ($lang === '') { | ||
$lang = $this->getEnvLang(); | ||
} | ||
|
||
return $this->getSparql()->queryConceptSchemes($lang); | ||
$conceptSchemes = null; | ||
try { | ||
$conceptSchemes = $this->getSparql()->queryConceptSchemes($lang); | ||
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { | ||
if ($this->model->getConfig()->getLogCaughtExceptions()) { | ||
error_log('Caught exception: ' . $e->getMessage()); | ||
} | ||
} | ||
return $conceptSchemes; | ||
} | ||
|
||
/** | ||
|
@@ -418,8 +432,15 @@ public function getConceptRelateds($uri, $lang) | |
public function getConceptInfo($uri, $clang) | ||
{ | ||
$sparql = $this->getSparql(); | ||
|
||
return $sparql->queryConceptInfo($uri, $this->config->getArrayClassURI(), array($this), $clang); | ||
$conceptInfo = null; | ||
try { | ||
$conceptInfo = $sparql->queryConceptInfo($uri, $this->config->getArrayClassURI(), array($this), $clang); | ||
} catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) { | ||
if ($this->model->getConfig()->getLogCaughtExceptions()) { | ||
error_log('Caught exception: ' . $e->getMessage()); | ||
} | ||
} | ||
return $conceptInfo; | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -835,7 +835,7 @@ $(function() { // DOCUMENT READY | |
$('.search-result-listing').append($ready); | ||
} | ||
else { | ||
$trigger.waypoint(function() { waypointCallback(); }, options); | ||
$trigger.waypoint(function() { waypointCallback(this); }, options); | ||
} | ||
} | ||
|
||
|
@@ -881,9 +881,13 @@ $(function() { // DOCUMENT READY | |
changeOffset += 200; | ||
} | ||
|
||
function waypointCallback() { | ||
function waypointCallback(waypoint) { | ||
if ($('.search-result-listing > p .spinner,.search-result-listing .alert-danger').length > 0) { | ||
return false; | ||
} | ||
var number_of_hits = $(".search-result").length; | ||
if (number_of_hits < parseInt($('.search-count p').text().substr(0, $('.search-count p').text().indexOf(' ')), 10)) { $('.search-result-listing').append($loading); | ||
if (number_of_hits < parseInt($('.search-count p').text().substr(0, $('.search-count p').text().indexOf(' ')), 10)) { | ||
$('.search-result-listing').append($loading); | ||
var typeLimit = $('#type-limit').val(); | ||
var schemeLimit = $('#scheme-limit').val(); | ||
var groupLimit = $('#group-limit').val(); | ||
|
@@ -903,7 +907,20 @@ $(function() { // DOCUMENT READY | |
$('.search-result-listing').append($ready); | ||
return false; | ||
} | ||
$('.search-result:nth-last-of-type(4)').waypoint(function() { waypointCallback(); }, options ); | ||
waypoint.destroy(); | ||
$('.search-result:nth-last-of-type(4)').waypoint(function() { waypointCallback(this); }, options ); | ||
}, | ||
error: function(jqXHR, textStatus, errorThrown) { | ||
$loading.detach(); | ||
var $failedSearch = $('<div class="alert alert-danger"><h4>Error: Loading for more items failed!</h4></div>'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This error message should be translated |
||
var $retryButton = $('<button class="btn btn-default" type="button">Retry</button>'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Retry" should be translated as well |
||
$retryButton.on('click', function () { | ||
$failedSearch.remove(); | ||
waypointCallback(waypoint); | ||
return false; | ||
}); | ||
$failedSearch.append($retryButton) | ||
$('.search-result-listing').append($failedSearch); | ||
} | ||
}); | ||
} | ||
|
@@ -1042,9 +1059,9 @@ $(function() { // DOCUMENT READY | |
} | ||
|
||
/* makes an AJAX query for the alphabetical index contents when landing on | ||
* the vocabulary home page. | ||
* the vocabulary home page or on the vocabulary concept error page. | ||
*/ | ||
if ($('#alpha').hasClass('active') && $('#vocab-info').length === 1 && $('.alphabetical-search-results').length === 0) { | ||
if ($('#alpha').hasClass('active') && $('#vocab-info,.page-alert').length == 1 && $('.alphabetical-search-results').length == 0) { | ||
// taking into account the possibility that the lang parameter has been changed by the WebController. | ||
var urlLangCorrected = vocab + '/' + lang + '/index?limit=250&offset=0&clang=' + clang; | ||
$('.sidebar-grey').empty().append('<div class="loading-spinner"><span class="spinner-text">'+ loading_text + '</span><span class="spinner" /></div>'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
{% extends "light.twig" %} | ||
{% block title %}: Error page{% endblock %} | ||
{% block error %} | ||
<div class="alert {% if request.vocabid != '' or request.page == 'feedback' or request.page == 'about' %}page-alert{% else %}frontpage-alert{% endif %}"> | ||
<h3>{% if not message %}{% trans %}404 Error: The page {{ requested_page }} cannot be found.{% endtrans %}{% else %}{{ message }}{% endif %}</h3> | ||
{% spaceless %} | ||
{% set pageError = request.vocabid != '' and request.page == 'page' %} | ||
{% if pageError %} | ||
<div id="maincontent"> | ||
<div class="content"> | ||
{% endif %} | ||
<div class="alert {% if request.vocabid != '' or request.page == 'feedback' or request.page == 'about' %}page-alert{% else %}frontpage-alert{% endif %}"> | ||
<h3>{% if not message %}{% trans %}404 Error: The page {{ requested_page }} cannot be found.{% endtrans %}{% else %}{{ message }}{% endif %}</h3> | ||
</div> | ||
{% if pageError %} | ||
</div> | ||
</div> | ||
{% endif %} | ||
{% endspaceless %} | ||
{% endblock %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An empty catch block is bad practice. What happens with the
$vocabObjects
variable that is used below?At a minimum, it could be set to
null
here, orarray()
if that makes more sense.