[ML] Fixing error reporting in message bar (#18781)

This commit is contained in:
James Gowdy 2018-05-03 18:33:22 +01:00 committed by GitHub
parent 6486db7280
commit 708810ab30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 13 deletions

View file

@ -493,7 +493,7 @@ module
.catch((err) => {
// TODO - display error in cards saying data could not be loaded.
console.log('DataVisualizer - error getting stats for metric cards from elasticsearch:', err);
if (err.status === 500) {
if (err.statusCode === 500) {
notify.error(`Error loading data for metrics in index ${indexPattern.title}. ${err.message}. ` +
'The request may have timed out. Try using a smaller sample size or narrowing the time range.',
{ lifetime: 30000 });
@ -544,7 +544,7 @@ module
.catch((err) => {
// TODO - display error in cards saying data could not be loaded.
console.log('DataVisualizer - error getting non metric field stats from elasticsearch:', err);
if (err.status === 500) {
if (err.statusCode === 500) {
notify.error(`Error loading data for fields in index ${indexPattern.title}. ${err.message}. ` +
'The request may have timed out. Try using a smaller sample size or narrowing the time range.',
{ lifetime: 30000 });
@ -594,7 +594,7 @@ module
.catch((err) => {
// TODO - display error in cards saying data could not be loaded.
console.log('DataVisualizer - error getting overall stats from elasticsearch:', err);
if (err.status === 500) {
if (err.statusCode === 500) {
notify.error(`Error loading data for fields in index ${indexPattern.title}. ${err.message}. ` +
'The request may have timed out. Try using a smaller sample size or narrowing the time range.',
{ lifetime: 30000 });

View file

@ -95,16 +95,17 @@ module.controller('MlJobTimepickerModal', function (
doStart();
})
.catch((resp) => {
if (resp.status === 409) {
if (resp.statusCode === 409) {
doStart();
} else {
if (resp.status === 500) {
if (resp.statusCode === 500) {
if (doStartCalled === false) {
// doStart hasn't been called yet, this 500 has returned before 10s,
// so it's not due to a timeout
msgs.error(`Could not open ${$scope.jobId}`, resp);
}
} else {
// console.log(resp);
msgs.error(`Could not open ${$scope.jobId}`, resp);
}
$scope.saveLock = false;

View file

@ -30,7 +30,7 @@ export function getMlNodeCount() {
})
.catch((error) => {
mlNodeCount = 0;
if (error.status === 403) {
if (error.statusCode === 403) {
userHasPermissionToViewMlNodeCount = false;
} else {
console.error(error);

View file

@ -39,11 +39,7 @@ export function http(options) {
fetch(url, payload)
.then((resp) => {
if (resp.ok === true) {
resolve(resp.json());
} else {
reject(resp);
}
resp.json().then((resp.ok === true) ? resolve : reject);
})
.catch((resp) => {
reject(resp);

View file

@ -492,7 +492,7 @@ class JobService {
}
function deleteFailed(resp, txt) {
if (resp.status === 500) {
if (resp.statusCode === 500) {
status.errorMessage = txt;
}
reject({ success: false });
@ -905,7 +905,7 @@ class JobService {
})
.catch((err) => {
console.log('jobService error stopping datafeed:', err);
if (err.status === 500) {
if (err.statusCode === 500) {
msgs.error('Could not stop datafeed for ' + jobId);
msgs.error('Request may have timed out and may still be running in the background.');
} else {