Skip to content

Commit 162f8b2

Browse files
fix(exception): send proper code and message
1 parent c80ce87 commit 162f8b2

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { Appwrite } from "appwrite";
3333
To install with a CDN (content delivery network) add the following scripts to the bottom of your <body> tag, but before you use any Appwrite services:
3434

3535
```html
36-
<script src="https://cdn.jsdelivr.net/npm/[email protected].0"></script>
36+
<script src="https://cdn.jsdelivr.net/npm/[email protected].1"></script>
3737
```
3838

3939

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "appwrite",
33
"homepage": "https://appwrite.io/support",
44
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5-
"version": "4.0.0",
5+
"version": "4.0.1",
66
"license": "BSD-3-Clause",
77
"main": "dist/cjs/sdk.js",
88
"exports": {

src/sdk.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class Appwrite {
7979
locale: '',
8080
};
8181
headers: Headers = {
82-
'x-sdk-version': 'appwrite:web:4.0.0',
82+
'x-sdk-version': 'appwrite:web:4.0.1',
8383
'X-Appwrite-Response-Format': '0.10.0',
8484
};
8585

@@ -192,7 +192,7 @@ class Appwrite {
192192
},
193193
authenticate: (event) => {
194194
const message: RealtimeResponse = JSON.parse(event.data);
195-
if (message.type === 'connected') {
195+
if (message.type === 'connected' && this.realtime.socket?.readyState === WebSocket.OPEN) {
196196
const cookie = JSON.parse(window.localStorage.getItem('cookieFallback') ?? "{}");
197197
const session = cookie?.[`a_session_${this.config.project}`];
198198
const data = <RealtimeResponseConnected>message.data;
@@ -347,6 +347,9 @@ class Appwrite {
347347

348348
return data;
349349
} catch (e) {
350+
if (e instanceof AppwriteException) {
351+
throw e;
352+
}
350353
throw new AppwriteException((<Error>e).message);
351354
}
352355
}
@@ -2625,4 +2628,4 @@ class Appwrite {
26252628
};
26262629

26272630
export { Appwrite }
2628-
export type { AppwriteException }
2631+
export type { AppwriteException }

0 commit comments

Comments
 (0)