--- a/server/src/app/Services/BnfResolver.php Thu Feb 09 17:22:58 2017 +0100
+++ b/server/src/app/Services/BnfResolver.php Fri Feb 10 12:03:12 2017 +0100
@@ -3,6 +3,8 @@
use Cache;
use CorpusParole\Services\BnfResolverInterface;
+use CorpusParole\Services\BnfResolverTimeoutException;
+use EasyRdf;
class BnfResolver implements BnfResolverInterface {
@@ -84,7 +86,20 @@
}
$query .= "}";
- $docs = $this->sparqlClient->query($query);
+ try {
+ $docs = $this->sparqlClient->query($query);
+ } catch (EasyRdf\Exception $e) {
+ $code = 0;
+ if(method_exists($e, 'getCode')) {
+ $code = $e->getCode();
+ }
+ $message = $e->getMessage();
+ if($code == 400 || ($code == 0 && stripos($message, 'timed out')>=0) ) {
+ throw new BnfResolverTimeoutException("Query to bnf server timed out.");
+ }
+ // reraise the original exception
+ throw $e;
+ }
$resultsRaw = [];