Skip to content

Commit dbd4e2a

Browse files
committed
handle the gid not found error
1 parent 38e44dc commit dbd4e2a

File tree

1 file changed

+15
-6
lines changed
  • services/static-webserver/client/source/class/osparc/store

1 file changed

+15
-6
lines changed

services/static-webserver/client/source/class/osparc/store/Users.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ qx.Class.define("osparc.store.Users", {
2828
},
2929

3030
members: {
31-
fetchUser: function(groupId) {
31+
__fetchUser: function(groupId) {
3232
const params = {
3333
url: {
3434
gid: groupId
@@ -41,14 +41,23 @@ qx.Class.define("osparc.store.Users", {
4141
});
4242
},
4343

44-
getUser: function(groupId, fetchIfNotFound = true) {
44+
getUser: async function(groupId, fetchIfNotFound = true) {
4545
const userFound = this.getUsers().find(user => user.getGroupId() === groupId);
4646
if (userFound) {
47-
return new Promise(resolve => resolve(userFound));
48-
} else if (fetchIfNotFound) {
49-
return this.fetchUser(groupId);
47+
return userFound;
5048
}
51-
return new Promise(reject => reject());
49+
if (fetchIfNotFound) {
50+
try {
51+
const user = await this.__fetchUser(groupId);
52+
if (user) {
53+
return user;
54+
}
55+
} catch (error) {
56+
console.error(error);
57+
return null;
58+
}
59+
}
60+
return null;
5261
},
5362

5463
addUser: function(userData) {

0 commit comments

Comments
 (0)