Return null on error

Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
RMidhunSuresh 2021-08-02 23:42:55 +05:30
parent bb68b4d367
commit e363d32921

View file

@ -108,7 +108,16 @@ async function loadMember({roomId, userId, storage}) {
} }
async function fetchMember({roomId, userId, hsApi, storage}, log) { async function fetchMember({roomId, userId, hsApi, storage}, log) {
const memberData = await hsApi.state(roomId, "m.room.member", userId, {log}).response(); let memberData;
try {
memberData = await hsApi.state(roomId, "m.room.member", userId, { log }).response();
}
catch (error) {
if (error.name === "HomeServerError" && error.errcode === "M_NOT_FOUND") {
return null;
}
throw error;
}
const member = new RoomMember({ const member = new RoomMember({
roomId, roomId,
userId, userId,