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