From ba38ce7976c8bac43a06a7e8a776c7b358bee1b8 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 9 Apr 2021 16:30:53 +0200 Subject: [PATCH] use canonical way of check error type --- src/matrix/SessionContainer.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/matrix/SessionContainer.js b/src/matrix/SessionContainer.js index 5191e745..55acd4e7 100644 --- a/src/matrix/SessionContainer.js +++ b/src/matrix/SessionContainer.js @@ -21,7 +21,6 @@ import {Reconnector, ConnectionStatus} from "./net/Reconnector.js"; import {ExponentialRetryDelay} from "./net/ExponentialRetryDelay.js"; import {MediaRepository} from "./net/MediaRepository.js"; import {RequestScheduler} from "./net/RequestScheduler.js"; -import {HomeServerError, ConnectionError, AbortError} from "./error.js"; import {Sync, SyncStatus} from "./Sync.js"; import {Session} from "./Session.js"; @@ -124,7 +123,7 @@ export class SessionContainer { await this._platform.sessionInfoStorage.add(sessionInfo); } catch (err) { this._error = err; - if (err instanceof HomeServerError) { + if (err.name === "HomeServerError") { if (err.errcode === "M_FORBIDDEN") { this._loginFailure = LoginFailure.Credentials; } else { @@ -132,7 +131,7 @@ export class SessionContainer { } log.set("loginFailure", this._loginFailure); this._status.set(LoadStatus.LoginFailed); - } else if (err instanceof ConnectionError) { + } else if (err.name === "ConnectionError") { this._loginFailure = LoginFailure.Connection; this._status.set(LoadStatus.LoginFailed); } else { @@ -253,7 +252,7 @@ export class SessionContainer { } } catch (err) { // if dispose is called from stop, bail out - if (err instanceof AbortError) { + if (err.name === "AbortError") { return; } throw err;