forked from mystiq/hydrogen-web
fix #48
This commit is contained in:
parent
b8370d53b6
commit
16542284f3
1 changed files with 5 additions and 4 deletions
|
@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {HomeServerError} from "../error.js";
|
import {HomeServerError, ConnectionError} from "../error.js";
|
||||||
import {encodeQueryParams} from "./common.js";
|
import {encodeQueryParams} from "./common.js";
|
||||||
|
|
||||||
class RequestWrapper {
|
class RequestWrapper {
|
||||||
|
@ -26,8 +26,9 @@ class RequestWrapper {
|
||||||
if (response.status >= 200 && response.status < 300) {
|
if (response.status >= 200 && response.status < 300) {
|
||||||
return response.body;
|
return response.body;
|
||||||
} else {
|
} else {
|
||||||
switch (response.status) {
|
if (response.status >= 400 && !response.body?.errcode) {
|
||||||
default:
|
throw new ConnectionError(`HTTP error status ${response.status} without errcode in body, assume this is a load balancer complaining the server is offline.`);
|
||||||
|
} else {
|
||||||
throw new HomeServerError(method, url, response.body, response.status);
|
throw new HomeServerError(method, url, response.body, response.status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue