@tchain/tcabci-read-js-client 2.0.2 → 2.0.4
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.
- package/client.js +2 -3
- package/errors.js +18 -5
- package/errors_test.js +1 -1
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -24,7 +24,7 @@ export default class TCAbciClient {
|
|
|
24
24
|
subscribed = false
|
|
25
25
|
subscribedAddresses = []
|
|
26
26
|
connected = false
|
|
27
|
-
version = 'v2.0.
|
|
27
|
+
version = 'v2.0.4'
|
|
28
28
|
errorCb = null
|
|
29
29
|
listenCb = null
|
|
30
30
|
ws = null
|
|
@@ -54,7 +54,6 @@ export default class TCAbciClient {
|
|
|
54
54
|
req.cache = 'no-cache'
|
|
55
55
|
req.headers = {
|
|
56
56
|
Client: `tcabaci-read-js-client${this.version}`,
|
|
57
|
-
'X-Client': `tcabaci-read-js-client${this.version}`,
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
if (typeof AbortSignal !== 'undefined') {
|
|
@@ -67,7 +66,7 @@ export default class TCAbciClient {
|
|
|
67
66
|
if (response.ok) return response.json()
|
|
68
67
|
|
|
69
68
|
return Promise.reject(
|
|
70
|
-
new FetchError(response.statusText
|
|
69
|
+
new FetchError(response.statusText).setCode(response.status),
|
|
71
70
|
)
|
|
72
71
|
})
|
|
73
72
|
}
|
package/errors.js
CHANGED
|
@@ -13,17 +13,30 @@ export const ALREADY_CONNECTED = new Error('Already connected'),
|
|
|
13
13
|
TRANSACTION_NOT_BROADCAST = new Error('Transaction can not be broadcast')
|
|
14
14
|
|
|
15
15
|
export class FetchError extends Error {
|
|
16
|
-
message = ''
|
|
17
16
|
code = -1
|
|
18
17
|
response = {}
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
/**
|
|
20
|
+
* @param {string} message
|
|
21
|
+
*/
|
|
22
|
+
constructor(message) {
|
|
21
23
|
super(message)
|
|
22
|
-
this.
|
|
24
|
+
this.name = 'FetchError'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
setCode(code) {
|
|
23
28
|
this.code = code
|
|
29
|
+
|
|
30
|
+
return this
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
setResponse(data) {
|
|
24
34
|
this.response = {
|
|
25
|
-
status: code,
|
|
26
|
-
|
|
35
|
+
status: this.code,
|
|
36
|
+
message: this.message,
|
|
37
|
+
data: data,
|
|
27
38
|
}
|
|
39
|
+
|
|
40
|
+
return this
|
|
28
41
|
}
|
|
29
42
|
}
|
package/errors_test.js
CHANGED