From b69efc3425d0f3f9639ff1d92934e603e9061df8 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 17 Mar 2020 00:07:54 +0100 Subject: [PATCH] fix errors when replaying --- src/matrix/error.js | 8 ++++---- src/matrix/hs-api.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/matrix/error.js b/src/matrix/error.js index 888b1256..cf6db9c5 100644 --- a/src/matrix/error.js +++ b/src/matrix/error.js @@ -1,8 +1,8 @@ export class HomeServerError extends Error { - constructor(method, url, body) { - super(`${body.error} on ${method} ${url}`); - this.errcode = body.errcode; - this.retry_after_ms = body.retry_after_ms; + constructor(method, url, body, status) { + super(`${body ? body.error : status} on ${method} ${url}`); + this.errcode = body ? body.errcode : null; + this.retry_after_ms = body ? body.retry_after_ms : 0; } get isFatal() { diff --git a/src/matrix/hs-api.js b/src/matrix/hs-api.js index d4f9e1f7..ec8adad0 100644 --- a/src/matrix/hs-api.js +++ b/src/matrix/hs-api.js @@ -12,7 +12,7 @@ class RequestWrapper { } else { switch (response.status) { default: - throw new HomeServerError(method, url, response.body); + throw new HomeServerError(method, url, response.body, response.status); } } });