Fix fetchAgents error handling

This commit is contained in:
Jesús Ángel González 2018-07-03 12:53:09 +02:00
parent 0eba7b645d
commit cac38d12ac

View File

@ -276,11 +276,19 @@ app.controller('settingsController', function ($scope, $rootScope, $http, $route
$scope.currentDefault = JSON.parse(appState.getCurrentAPI()).id;
}
await Promise.all([
genericReq.request('GET', '/api/wazuh-api/fetchAgents'),
getSettings()
]);
try {
await genericReq.request('GET', '/api/wazuh-api/fetchAgents');
} catch (error) {
if(error && error.status && error.status === -1) {
errorHandler.handle('Wazuh API was inserted correctly, but something happened while fetching agents data.','Fetch agents',true);
} else {
errorHandler.handle(error,'Fetch agents');
}
}
await getSettings();
if(!$scope.$$phase) $scope.$digest();
return;