Skip to content

Commit

Permalink
[ML] Fixing error reporting in message bar (elastic#18781) (elastic#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed May 3, 2018
1 parent 7c5c610 commit 29dd460
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,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 });
Expand Down Expand Up @@ -545,7 +545,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 });
Expand Down Expand Up @@ -595,7 +595,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 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/ml/public/ml_nodes_check/check_ml_nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 1 addition & 5 deletions x-pack/plugins/ml/public/services/http_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/ml/public/services/job_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ class JobService {
}

function deleteFailed(resp, txt) {
if (resp.status === 500) {
if (resp.statusCode === 500) {
status.errorMessage = txt;
}
reject({ success: false });
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 29dd460

Please sign in to comment.