From 0bd0f788e36388d967afd0a83418359eeeb9bc9e Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 9 Mar 2021 12:51:34 +0100 Subject: [PATCH] consider all server errors as connection errors even if they do have an errcode fixes #223 --- src/matrix/net/HomeServerApi.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/matrix/net/HomeServerApi.js b/src/matrix/net/HomeServerApi.js index 7748ee23..8e7a110b 100644 --- a/src/matrix/net/HomeServerApi.js +++ b/src/matrix/net/HomeServerApi.js @@ -29,12 +29,17 @@ class RequestWrapper { log?.finish(); return response.body; } else { - if (response.status >= 400 && !response.body?.errcode) { + if (response.status >= 500) { + const err = new ConnectionError(`Internal Server Error`); + log?.catch(err); + throw err; + } else if (response.status >= 400 && !response.body?.errcode) { const err = new ConnectionError(`HTTP error status ${response.status} without errcode in body, assume this is a load balancer complaining the server is offline.`); log?.catch(err); throw err; } else { const err = new HomeServerError(method, url, response.body, response.status); + log?.set("errcode", err.errcode); log?.catch(err); throw err; }