better error handling in RoomBeingCreated

This commit is contained in:
Bruno Windels 2022-02-10 11:06:20 +01:00
parent d6d1af13d0
commit f12841b2d3

View File

@ -117,6 +117,7 @@ export class RoomBeingCreated extends EventEmitter<{change: never}> {
/** @internal */ /** @internal */
async create(hsApi: HomeServerApi, log: ILogItem): Promise<void> { async create(hsApi: HomeServerApi, log: ILogItem): Promise<void> {
try {
let avatarEventContent; let avatarEventContent;
if (this.options.avatar) { if (this.options.avatar) {
const {avatar} = this.options; const {avatar} = this.options;
@ -154,7 +155,6 @@ export class RoomBeingCreated extends EventEmitter<{change: never}> {
content: avatarEventContent content: avatarEventContent
}); });
} }
try {
const response = await hsApi.createRoom(createOptions, {log}).response(); const response = await hsApi.createRoom(createOptions, {log}).response();
this._roomId = response["room_id"]; this._roomId = response["room_id"];
} catch (err) { } catch (err) {
@ -170,6 +170,7 @@ export class RoomBeingCreated extends EventEmitter<{change: never}> {
* is running. */ * is running. */
/** @internal */ /** @internal */
async loadProfiles(hsApi: HomeServerApi, log: ILogItem): Promise<void> { async loadProfiles(hsApi: HomeServerApi, log: ILogItem): Promise<void> {
try {
// only load profiles if we need it for the room name and avatar // only load profiles if we need it for the room name and avatar
if (!this.options.name && this.options.invites) { if (!this.options.name && this.options.invites) {
this.profiles = await loadProfiles(this.options.invites, hsApi, log); this.profiles = await loadProfiles(this.options.invites, hsApi, log);
@ -180,6 +181,7 @@ export class RoomBeingCreated extends EventEmitter<{change: never}> {
this._calculatedName = calculateRoomName(this.profiles, summaryData, log); this._calculatedName = calculateRoomName(this.profiles, summaryData, log);
this.emitChange(); this.emitChange();
} }
} catch (err) {} // swallow error, loading profiles is not essential
} }
private emitChange(params?: string) { private emitChange(params?: string) {