Skip to content

Commit 9951a2a

Browse files
committed
Refactor sessions service with try/catch
1 parent be76037 commit 9951a2a

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/services/session.service.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ export const getActiveProxyAddresses = async (phoneNumbers: Array<String>) : Pro
1414
return activeConversations[phoneNumber] = proxyAddresses
1515
})
1616

17-
return Promise.all(promises)
18-
.then(() => {
19-
return activeConversations;
20-
})
21-
.catch(err => {
22-
console.log(err)
23-
throw new Error(err)
24-
})
17+
try {
18+
await Promise.all(promises)
19+
return activeConversations;
20+
} catch(err) {
21+
console.log(err)
22+
throw new Error(err)
23+
}
2524
}
2625

2726
export const matchAvailableProxyAddresses = async (activeProxyAddresses: ActiveProxyAddresses) : Promise<ProxyBindings> => {
@@ -68,12 +67,11 @@ export const addParticipantsToConversation = async (conversationSid: string, pro
6867
}
6968
}
7069

71-
return Promise.all(promises)
72-
.then((results) => {
73-
return results
74-
})
75-
.catch(err => {
76-
console.log(err)
77-
throw new Error(err)
78-
})
70+
try {
71+
const results = await Promise.all(promises)
72+
return results
73+
} catch(err) {
74+
console.log(err)
75+
throw new Error(err)
76+
}
7977
}

0 commit comments

Comments
 (0)