Handle 404s for agents
This commit is contained in:
parent
50a5bf4332
commit
9d9d66b1a7
|
@ -0,0 +1,10 @@
|
|||
import Ember from 'ember';
|
||||
import notifyError from 'nomad-ui/utils/notify-error';
|
||||
|
||||
const { Route } = Ember;
|
||||
|
||||
export default Route.extend({
|
||||
model() {
|
||||
return this._super(...arguments).catch(notifyError(this));
|
||||
},
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import ApplicationSerializer from './application';
|
||||
import { AdapterError } from 'ember-data/adapters/errors';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
attrs: {
|
||||
|
@ -8,6 +9,16 @@ export default ApplicationSerializer.extend({
|
|||
},
|
||||
|
||||
normalize(typeHash, hash) {
|
||||
if (!hash) {
|
||||
// It's unusual to throw an adapter error from a serializer,
|
||||
// but there is no single server end point so the serializer
|
||||
// acts like the API in this case.
|
||||
const error = new AdapterError([{ status: '404' }]);
|
||||
|
||||
error.message = 'Requested Agent was not found in set of available Agents';
|
||||
throw error;
|
||||
}
|
||||
|
||||
hash.ID = hash.Name;
|
||||
hash.Datacenter = hash.Tags && hash.Tags.dc;
|
||||
hash.Region = hash.Tags && hash.Tags.region;
|
||||
|
|
Loading…
Reference in New Issue