From b0fa3978fcfca28842f968c623280c0b57e199de Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Mon, 3 Jun 2024 15:02:25 -0300 Subject: [PATCH] throw the original underlining error instead of 'offline' --- package.json | 2 +- src/HTTP.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 620f479..d061533 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "colyseus.js", - "version": "0.15.20", + "version": "0.15.21", "description": "Colyseus Multiplayer SDK for JavaScript/TypeScript", "author": "Endel Dreyer", "license": "MIT", diff --git a/src/HTTP.ts b/src/HTTP.ts index a6d2259..e72f23b 100644 --- a/src/HTTP.ts +++ b/src/HTTP.ts @@ -25,7 +25,14 @@ export class HTTP { protected request(method: "get" | "post" | "put" | "del", path: string, options: Partial = {}): Promise { return httpie[method](this.client['getHttpEndpoint'](path), this.getOptions(options)).catch((e: any) => { - throw new ServerError(e.statusCode || -1, e.data?.error || e.statusMessage || e.message || "offline"); + const status = e.statusCode; // || -1 + const message = e.data?.error || e.statusMessage || e.message; // || "offline" + + if (status === undefined && message === undefined) { + throw e; + } + + throw new ServerError(status, message); }); }