@cripty2001/utils 0.0.90 → 0.0.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -73,30 +73,27 @@ class Client {
73
73
  },
74
74
  body: new Blob([new Uint8Array((0, msgpack_1.encode)(input))], { type: 'application/msgpack' }),
75
75
  });
76
+ if (res.status === 401 || res.status === 403) {
77
+ if (testedToken === this.authToken.value) {
78
+ this.setAuthToken(null);
79
+ }
80
+ throw new ClientError("Permission denied");
81
+ }
82
+ if (res.status === 404)
83
+ throw new ClientError("Not found");
76
84
  const decoded = (0, msgpack_1.decode)(await res.arrayBuffer());
77
85
  let responseData;
78
- switch (res.status) {
79
- case 404:
80
- throw new ClientError("Not found");
81
- case 401:
82
- case 403:
83
- if (testedToken === this.authToken.value) {
84
- this.setAuthToken(null);
85
- }
86
- throw new ClientError("Permission denied");
87
- case 200:
88
- responseData = decoded;
89
- return responseData;
90
- case 422:
91
- responseData = decoded;
92
- throw new ClientValidationError(responseData.errors);
93
- case 400:
94
- case 500:
95
- responseData = decoded;
96
- throw new ClientServerError(responseData.code, responseData.error, responseData.payload);
97
- default:
98
- throw new ClientError(`Unexpected server response: ${res.status}`);
86
+ if (res.status === 200)
87
+ return decoded;
88
+ if (res.status === 422) {
89
+ responseData = decoded;
90
+ throw new ClientValidationError(responseData.errors);
91
+ }
92
+ if (res.status === 400 || res.status === 500) {
93
+ responseData = decoded;
94
+ throw new ClientServerError(responseData.code, responseData.error, responseData.payload);
99
95
  }
96
+ throw new ClientError(`Unexpected server response: ${res.status}`);
100
97
  }
101
98
  }
102
99
  exports.Client = Client;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.90",
3
+ "version": "0.0.91",
4
4
  "description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
5
5
  "homepage": "https://github.com/cripty2001/utils#readme",
6
6
  "bugs": {