use canonical way of check error type
This commit is contained in:
parent
b852feeb9c
commit
ba38ce7976
1 changed files with 3 additions and 4 deletions
|
@ -21,7 +21,6 @@ import {Reconnector, ConnectionStatus} from "./net/Reconnector.js";
|
||||||
import {ExponentialRetryDelay} from "./net/ExponentialRetryDelay.js";
|
import {ExponentialRetryDelay} from "./net/ExponentialRetryDelay.js";
|
||||||
import {MediaRepository} from "./net/MediaRepository.js";
|
import {MediaRepository} from "./net/MediaRepository.js";
|
||||||
import {RequestScheduler} from "./net/RequestScheduler.js";
|
import {RequestScheduler} from "./net/RequestScheduler.js";
|
||||||
import {HomeServerError, ConnectionError, AbortError} from "./error.js";
|
|
||||||
import {Sync, SyncStatus} from "./Sync.js";
|
import {Sync, SyncStatus} from "./Sync.js";
|
||||||
import {Session} from "./Session.js";
|
import {Session} from "./Session.js";
|
||||||
|
|
||||||
|
@ -124,7 +123,7 @@ export class SessionContainer {
|
||||||
await this._platform.sessionInfoStorage.add(sessionInfo);
|
await this._platform.sessionInfoStorage.add(sessionInfo);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this._error = err;
|
this._error = err;
|
||||||
if (err instanceof HomeServerError) {
|
if (err.name === "HomeServerError") {
|
||||||
if (err.errcode === "M_FORBIDDEN") {
|
if (err.errcode === "M_FORBIDDEN") {
|
||||||
this._loginFailure = LoginFailure.Credentials;
|
this._loginFailure = LoginFailure.Credentials;
|
||||||
} else {
|
} else {
|
||||||
|
@ -132,7 +131,7 @@ export class SessionContainer {
|
||||||
}
|
}
|
||||||
log.set("loginFailure", this._loginFailure);
|
log.set("loginFailure", this._loginFailure);
|
||||||
this._status.set(LoadStatus.LoginFailed);
|
this._status.set(LoadStatus.LoginFailed);
|
||||||
} else if (err instanceof ConnectionError) {
|
} else if (err.name === "ConnectionError") {
|
||||||
this._loginFailure = LoginFailure.Connection;
|
this._loginFailure = LoginFailure.Connection;
|
||||||
this._status.set(LoadStatus.LoginFailed);
|
this._status.set(LoadStatus.LoginFailed);
|
||||||
} else {
|
} else {
|
||||||
|
@ -253,7 +252,7 @@ export class SessionContainer {
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// if dispose is called from stop, bail out
|
// if dispose is called from stop, bail out
|
||||||
if (err instanceof AbortError) {
|
if (err.name === "AbortError") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
|
|
Reference in a new issue