More in deep Elastic error messages, now in backend

This commit is contained in:
Jesús Ángel González 2018-02-08 16:32:55 +01:00 committed by Javier Castro
parent bfe3b29287
commit 22e024e750
5 changed files with 9 additions and 11 deletions

View File

@ -4,7 +4,7 @@ const app = require('ui/modules').get('app/wazuh', []);
app.controller('blankScreenController', function ($scope, $rootScope, errorHandler) {
$scope.error = '';
if($rootScope.blankScreenError) {
$scope.error = $rootScope.blankScreenError;
$scope.error = errorHandler.handle($rootScope.blankScreenError,'',false,true);
delete $rootScope.blankScreenError;
}
});

View File

@ -7,7 +7,8 @@ app.service('errorHandler', function ( Notifier, appState, $location) {
if(error.data && error.data.errorData && error.data.errorData.message) return error.data.errorData.message;
if(error.errorData && error.errorData.message) return error.errorData.message;
if(error.data && typeof error.data === 'string') return error.data;
if(error.data && error.data.message) return error.data.message;
if(error.data && error.data.message && error.data.message === 'string') return error.data.message;
if(error.data && error.data.message && error.data.message.msg && error.data.message.msg === 'string') return error.data.message.msg;
if(error.data && error.data.data && typeof error.data.data === 'string') return error.data.data;
if(typeof error.message === 'string') return error.message;
if(error.message && error.message.msg) return error.message.msg;

View File

@ -31,10 +31,7 @@ module.exports = err => {
err.message = `Unexpected error filtering the data. Error ${err.message}.`;
} else if(err.message) {
err['html'] = err.message;
} else {
err['html'] = "Unexpected error. Please, report this error.";
err.message = "Unexpected error. Please, report this error.";
}
}
return err;
};

View File

@ -178,20 +178,20 @@ const getIp = (Promise, courier, config, $q, $rootScope, $window, $location, Pri
})
.catch(error => {
deferred.reject(error);
$rootScope.blankScreenError = errorHandler.handle(error,'Elasticsearch');
$rootScope.blankScreenError = errorHandler.handle(error,'Elasticsearch',false,true);
$location.path('/blank-screen');
});
})
.catch(error => {
deferred.reject(error);
$rootScope.blankScreenError = errorHandler.handle(error,'Elasticsearch');
$rootScope.blankScreenError = errorHandler.handle(error,'Elasticsearch',false,true);
$location.path('/blank-screen');
});
})
.catch(error => {
deferred.reject(error);
$rootScope.blankScreenError = errorHandler.handle(error,'Elasticsearch');
$rootScope.blankScreenError = errorHandler.handle(error,'Elasticsearch',false,true);
$location.path('/blank-screen');
});
}

View File

@ -286,7 +286,7 @@ module.exports = (server, options) => {
reply({
'statusCode': 500,
'error': 10000,
'message': error
'message': (error && error.message) ? error.message : error
}).code(500);
});
};