diff --git a/src/matrix/SendScheduler.js b/src/matrix/SendScheduler.js index 3beb4fa1..ac6e557f 100644 --- a/src/matrix/SendScheduler.js +++ b/src/matrix/SendScheduler.js @@ -1,5 +1,5 @@ import Platform from "../Platform.js"; -import {HomeServerError, NetworkError} from "./error.js"; +import {HomeServerError, ConnectionError} from "./error.js"; export class RateLimitingBackoff { constructor() { @@ -88,7 +88,7 @@ export class SendScheduler { // this can throw! result = await this._doSend(request.sendCallback); } catch (err) { - if (err instanceof NetworkError) { + if (err instanceof ConnectionError) { // we're offline, everybody will have // to re-request slots when we come back online this._offline = true; diff --git a/src/matrix/SessionContainer.js b/src/matrix/SessionContainer.js index 78c63560..b71fd213 100644 --- a/src/matrix/SessionContainer.js +++ b/src/matrix/SessionContainer.js @@ -81,7 +81,7 @@ export class SessionContainer { this._loginFailure = LoginFailure.Unknown; } this._status.set(LoadStatus.LoginFailure); - } else if (err instanceof NetworkError) { + } else if (err instanceof ConnectionError) { this._loginFailure = LoginFailure.Network; this._status.set(LoadStatus.LoginFailure); } else { @@ -150,10 +150,10 @@ export class SessionContainer { try { await this._sync.start(); } catch (err) { - // swallow NetworkError here and continue, + // swallow ConnectionError here and continue, // as the reconnector above will call // sync.start again to retry in this case - if (!(err instanceof NetworkError)) { + if (!(err instanceof ConnectionError)) { throw err; } } diff --git a/src/matrix/error.js b/src/matrix/error.js index 2ba95037..a4979952 100644 --- a/src/matrix/error.js +++ b/src/matrix/error.js @@ -15,5 +15,5 @@ export class HomeServerError extends Error { export {AbortError} from "../utils/error.js"; -export class NetworkError extends Error { +export class ConnectionError extends Error { } diff --git a/src/matrix/net/HomeServerApi.js b/src/matrix/net/HomeServerApi.js index 755d4825..cba5e591 100644 --- a/src/matrix/net/HomeServerApi.js +++ b/src/matrix/net/HomeServerApi.js @@ -1,6 +1,6 @@ import { HomeServerError, - NetworkError, + ConnectionError, } from "./error.js"; class RequestWrapper { @@ -85,7 +85,7 @@ export default class HomeServerApi { if (this._reconnector) { wrapper.response().catch(err => { - if (err instanceof NetworkError) { + if (err instanceof ConnectionError) { this._reconnector.onRequestFailed(this); } }); diff --git a/src/matrix/net/Reconnector.js b/src/matrix/net/Reconnector.js index ea2c86bf..fb83704e 100644 --- a/src/matrix/net/Reconnector.js +++ b/src/matrix/net/Reconnector.js @@ -1,6 +1,6 @@ import createEnum from "../../utils/enum.js"; import {AbortError} from "../../utils/error.js"; -import {NetworkError} from "../error.js" +import {ConnectionError} from "../error.js" import ObservableValue from "../../observable/ObservableValue.js"; export const ConnectionStatus = createEnum( @@ -93,7 +93,7 @@ export class Reconnector { this._versionsResponse = await versionsRequest.response(); this._setState(ConnectionStatus.Online); } catch (err) { - if (err instanceof NetworkError) { + if (err instanceof ConnectionError) { this._setState(ConnectionStatus.Waiting); try { await this._retryDelay.waitForRetry(); @@ -122,7 +122,7 @@ export function tests() { response() { if (remainingFailures) { remainingFailures -= 1; - return Promise.reject(new NetworkError()); + return Promise.reject(new ConnectionError()); } else { return Promise.resolve(42); } diff --git a/src/matrix/net/request/fetch.js b/src/matrix/net/request/fetch.js index 76929c6b..dff1c527 100644 --- a/src/matrix/net/request/fetch.js +++ b/src/matrix/net/request/fetch.js @@ -1,6 +1,6 @@ import { AbortError, - NetworkError + ConnectionError } from "../error.js"; class RequestResult { @@ -58,7 +58,7 @@ export default function fetchRequest(url, options) { // // One could check navigator.onLine to rule out the first // but the 2 latter ones are indistinguishable from javascript. - throw new NetworkError(`${options.method} ${url}: ${err.message}`); + throw new ConnectionError(`${options.method} ${url}: ${err.message}`); } throw err; }); diff --git a/src/matrix/net/request/replay.js b/src/matrix/net/request/replay.js index f47e6d47..916de9d6 100644 --- a/src/matrix/net/request/replay.js +++ b/src/matrix/net/request/replay.js @@ -1,6 +1,6 @@ import { AbortError, - NetworkError + ConnectionError } from "../error.js"; class RequestLogItem { @@ -24,7 +24,7 @@ class RequestLogItem { this.end = performance.now(); this.error = { aborted: err instanceof AbortError, - network: err instanceof NetworkError, + network: err instanceof ConnectionError, message: err.message, }; } @@ -98,7 +98,7 @@ class ReplayRequestResult { if (error.aborted || this._aborted) { throw new AbortError(error.message); } else if (error.network) { - throw new NetworkError(error.message); + throw new ConnectionError(error.message); } else { throw new Error(error.message); } diff --git a/src/matrix/room/sending/SendQueue.js b/src/matrix/room/sending/SendQueue.js index 3c9f90c3..caea41fa 100644 --- a/src/matrix/room/sending/SendQueue.js +++ b/src/matrix/room/sending/SendQueue.js @@ -1,5 +1,5 @@ import SortedArray from "../../../observable/list/SortedArray.js"; -import {NetworkError} from "../../error.js"; +import {ConnectionError} from "../../error.js"; import PendingEvent from "./PendingEvent.js"; function makeTxnId() { @@ -52,7 +52,7 @@ export default class SendQueue { console.log("keep sending?", this._amountSent, "<", this._pendingEvents.length); } } catch(err) { - if (err instanceof NetworkError) { + if (err instanceof ConnectionError) { this._offline = true; } } finally {