Skip to content

Commit

Permalink
combining job creation error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Sep 9, 2020
1 parent 1f4ab4d commit 9027b2a
Showing 1 changed file with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,7 @@ export const SummaryStep: FC<StepProps> = ({ setCurrentStep, isCurrentStep }) =>
const jr = await jobCreator.createAndStartJob();
setJobRunner(jr);
} catch (error) {
// catch and display all job creation errors
const { displayErrorToast } = toastNotificationServiceProvider(notifications.toasts);
displayErrorToast(
error,
i18n.translate('xpack.ml.newJob.wizard.summaryStep.createJobError', {
defaultMessage: `Job creation error`,
})
);
setCreatingJob(false);
handleJobCreationError(error);
}
}

Expand All @@ -91,18 +83,21 @@ export const SummaryStep: FC<StepProps> = ({ setCurrentStep, isCurrentStep }) =>
await jobCreator.createDatafeed();
advancedStartDatafeed(jobCreator, navigateToPath);
} catch (error) {
// catch and display all job creation errors
const { displayErrorToast } = toastNotificationServiceProvider(notifications.toasts);
displayErrorToast(
error,
i18n.translate('xpack.ml.newJob.wizard.summaryStep.createJobError', {
defaultMessage: `Job creation error`,
})
);
setCreatingJob(false);
handleJobCreationError(error);
}
}

function handleJobCreationError(error: any) {
const { displayErrorToast } = toastNotificationServiceProvider(notifications.toasts);
displayErrorToast(
error,
i18n.translate('xpack.ml.newJob.wizard.summaryStep.createJobError', {
defaultMessage: `Job creation error`,
})
);
setCreatingJob(false);
}

function viewResults() {
const url = mlJobService.createResultsUrl(
[jobCreator.jobId],
Expand Down

0 comments on commit 9027b2a

Please sign in to comment.