Skip to content

Commit 0bcb8b5

Browse files
authored
feat: add try catch block to await in application route (#3412)
1 parent e7b88e1 commit 0bcb8b5

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

app/routes/application.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,24 @@ export default Route.extend(ApplicationRouteMixin, {
2828
async model() {
2929
let notifications = [];
3030
if (this.get('session.isAuthenticated')) {
31-
notifications = await this.authManager.currentUser.query('notifications', {
32-
filter: [
33-
{
34-
name : 'is-read',
35-
op : 'eq',
36-
val : false
37-
}
38-
],
39-
sort: '-received-at'
40-
});
31+
try {
32+
notifications = await this.authManager.currentUser.query('notifications', {
33+
filter: [
34+
{
35+
name : 'is-read',
36+
op : 'eq',
37+
val : false
38+
}
39+
],
40+
sort: '-received-at'
41+
});
42+
} catch (e) {
43+
console.warn(e);
44+
this.session.invalidate();
45+
}
4146
}
4247

48+
4349
return {
4450
notifications,
4551
pages: await this.store.query('page', {

0 commit comments

Comments
 (0)