mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-06 09:55:18 +00:00
Continue managing errors in a better way (in progress)
This commit is contained in:
parent
1aa5b609d5
commit
7c2bb41d1b
@ -35,7 +35,7 @@ app.service('testAPI', function ($http, $location, $rootScope, appState, generic
|
||||
|
||||
appState.setPatternSelector(typeof configuration.data.data['ip.selector'] !== 'undefined' ? configuration.data.data['ip.selector'] : true)
|
||||
|
||||
return 'cookies_outdated';
|
||||
return 'cookies_outdated'
|
||||
/** End of checks for outdated cookies */
|
||||
|
||||
} else {
|
||||
@ -57,7 +57,6 @@ app.service('testAPI', function ($http, $location, $rootScope, appState, generic
|
||||
if(error.status && error.status === -1){
|
||||
$rootScope.apiIsDown = true;
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
|
||||
}
|
||||
|
@ -127,7 +127,14 @@ const settingsWizard = ($rootScope, $location, $q, $window, testAPI, appState, g
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => errorHandler.handle(error,'Routes'));
|
||||
.catch(error => {
|
||||
appState.removeCurrentAPI();
|
||||
errorHandler.handle(error,'Routes');
|
||||
errorHandler.handle('Wazuh App: please add a new API.','Routes',true);
|
||||
$location.search('_a', null);
|
||||
$location.search('tab', 'api');
|
||||
$location.path('/settings');
|
||||
});
|
||||
}
|
||||
|
||||
if (!$location.path().includes("/health-check") && healthCheck($window, $rootScope)) {
|
||||
|
@ -26,12 +26,14 @@ export default (message = null, code = null, statusCode = null, reply) => {
|
||||
filteredMessage = 'Wrong URL being used to connect to the Wazuh API'
|
||||
} else if(typeof message === 'string' && message.includes('ECONNREFUSED') && code === 3005) {
|
||||
filteredMessage = 'Wrong port being used to connect to the Wazuh API'
|
||||
} else if(typeof message === 'string' && message.toLowerCase().includes('not found') && code === 3002) {
|
||||
filteredMessage = 'Wazuh API entry not found'
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return reply({
|
||||
message: filteredMessage ? filteredMessage :
|
||||
message: filteredMessage ? `${code ? code : 1000} - ${filteredMessage}` :
|
||||
typeof message === 'string' ?
|
||||
`${code ? code : 1000} - ${message}` :
|
||||
`${code ? code : 1000} - Unexpected error`,
|
||||
|
@ -36,13 +36,11 @@ export default class WazuhApi {
|
||||
if(!protectedRoute(req)) return ErrorResponse('Session expired', 3001, 401, reply);
|
||||
// Get config from elasticsearch
|
||||
const wapi_config = await this.wzWrapper.getWazuhConfigurationById(req.payload)
|
||||
|
||||
console.log(wapi_config)
|
||||
if (wapi_config.error_code > 1) {
|
||||
// Can not connect to elasticsearch
|
||||
throw new Error(`Could not connect with elasticsearch, maybe it's down.`)
|
||||
throw new Error(`Could not find Wazuh API entry on Elasticsearch.`)
|
||||
} else if (wapi_config.error_code > 0) {
|
||||
// Credentials not found
|
||||
throw new Error('Valid credentials not found in elasticsearch. It seems the credentials were not saved.')
|
||||
throw new Error('Valid credentials not found in Elasticsearch. It seems the credentials were not saved.')
|
||||
}
|
||||
|
||||
let response = await needle('get', `${wapi_config.url}:${wapi_config.port}/version`, {}, {
|
||||
|
@ -360,7 +360,7 @@ export default class ElasticWrapper {
|
||||
};
|
||||
|
||||
} catch (error){
|
||||
return { error: 'no elasticsearch', error_code: 2 };
|
||||
return Promise.reject(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user