mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
rename NetworkError to ConnectionError
This commit is contained in:
parent
8c5411cb7d
commit
8c56ac3e4f
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
});
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user