Skip to content

Commit

Permalink
Move OTTExchangeError-creation into adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
backspace committed Apr 1, 2021
1 parent fa06c5e commit d5e2e5d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ui/app/adapters/token.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { inject as service } from '@ember/service';
import { default as ApplicationAdapter, namespace } from './application';
import OTTExchangeError from '../utils/ott-exchange-error';

export default class TokenAdapter extends ApplicationAdapter {
@service store;
Expand Down Expand Up @@ -29,6 +30,8 @@ export default class TokenAdapter extends ApplicationAdapter {
});

return store.peekRecord('token', store.normalize('token', token).data.id);
}).catch(() => {
throw new OTTExchangeError();
});
}
}
3 changes: 1 addition & 2 deletions ui/app/routes/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Route from '@ember/routing/route';
import { AbortError } from '@ember-data/adapter/error';
import RSVP from 'rsvp';
import { action } from '@ember/object';
import OTTExchangeError from '../utils/ott-exchange-error';
import classic from 'ember-classic-decorator';

@classic
Expand Down Expand Up @@ -38,7 +37,7 @@ export default class ApplicationRoute extends Route {
try {
await exchangeOneTimeToken;
} catch (e) {
this.controllerFor('application').set('error', new OTTExchangeError());
this.controllerFor('application').set('error', e);
}

const fetchSelfTokenAndPolicies = this.get('token.fetchSelfTokenAndPolicies')
Expand Down

0 comments on commit d5e2e5d

Please sign in to comment.