From 1e817cb35bfb3ba61f1c8a0dd8086031f92dca9e Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Thu, 28 Sep 2017 10:06:13 -0700 Subject: [PATCH] Handle 404s on jobs --- ui/app/routes/jobs/job.js | 4 +++- ui/app/utils/notify-error.js | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 ui/app/utils/notify-error.js diff --git a/ui/app/routes/jobs/job.js b/ui/app/routes/jobs/job.js index abe106775..5ae53a122 100644 --- a/ui/app/routes/jobs/job.js +++ b/ui/app/routes/jobs/job.js @@ -1,4 +1,5 @@ import Ember from 'ember'; +import notifyError from 'nomad-ui/utils/notify-error'; const { Route, inject } = Ember; @@ -10,6 +11,7 @@ export default Route.extend({ .find('job', job_id) .then(job => { return job.get('allocations').then(() => job); - }); + }) + .catch(notifyError(this)); }, }); diff --git a/ui/app/utils/notify-error.js b/ui/app/utils/notify-error.js new file mode 100644 index 000000000..3ca5f5987 --- /dev/null +++ b/ui/app/utils/notify-error.js @@ -0,0 +1,7 @@ +// An error handler to provide to a promise catch to set an error +// on the application controller. +export default function notifyError(route) { + return error => { + route.controllerFor('application').set('error', error); + }; +}