diff --git a/js/app/views/EpnTapUI.js b/js/app/views/EpnTapUI.js index 609a9a1..ebd7d22 100644 --- a/js/app/views/EpnTapUI.js +++ b/js/app/views/EpnTapUI.js @@ -67,11 +67,15 @@ Ext.create('Ext.data.Store', { type: 'ajax', url: 'php/epntap.php', extraParams: { action: 'resolver' } - // listeners: { - // exception: function(proxy, response, operation) { - // console.log('Error ', response); //TODO: Use ExtJs alert instead - // } - // } + }, + errorDisplayed: false, + listeners: { + load: function(store, records, successful) { + if(!successful && !store.errorDisplayed) { + Ext.Msg.alert('Error', 'Can not load results from the resolver. Please enter target names manually.'); + store.errorDisplayed = true; + } + } } }); @@ -121,7 +125,11 @@ Ext.create('Ext.data.Store', { {property: 'short_name', direction: 'ASC'} ], listeners: { - // load: function(record) { console.log(record); } + load: function(store, records, successful) { + if(!successful) { + Ext.Msg.alert('Error', 'Can not get epntap services from registries.'); + } + } } }); diff --git a/php/epntap.php b/php/epntap.php index 6e4c0e3..92b0ebf 100644 --- a/php/epntap.php +++ b/php/epntap.php @@ -41,14 +41,8 @@ function resolver() { $resolver_url = "http://voparis-registry.obspm.fr/ssodnet/1/autocomplete?q=%22$lastWord%22"; $response = ['success' => true, 'metaData' => ['root' => 'data', 'messageProperty' => 'msg']]; - try { - $content = file_get_contents($resolver_url); - } catch (Exception $e) { - error_log('Resolver access error: ' . $e); - $response['success'] = false; - $response['msg'] = "Resolver unreachable on $resolver_url."; - } - try { + $content = file_get_contents($resolver_url); + if($content) { $result = json_decode($content, true); $targets = array(); foreach($result['hits'] as $e) { @@ -58,10 +52,9 @@ function resolver() { array_push($targets, $target); } $response['data'] = $targets; - } catch (Exception $e) { - error_log('Resolver type error: ' . $e); + } else { $response['success'] = false; - $response['msg'] = 'The resolver returned a bad result.'; + $response['msg'] = "Resolver unreachable on $resolver_url."; } return $response; } -- libgit2 0.21.2