Skip to content

Commit

Permalink
throw the original underlining error instead of 'offline'
Browse files Browse the repository at this point in the history
  • Loading branch information
endel committed Jun 3, 2024
1 parent d6e0301 commit b0fa397
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 8 additions & 1 deletion src/HTTP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ export class HTTP {

protected request(method: "get" | "post" | "put" | "del", path: string, options: Partial<httpie.Options> = {}): Promise<httpie.Response> {
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);
});
}

Expand Down

0 comments on commit b0fa397

Please sign in to comment.