replica-bridge 0.3.20 → 0.3.22
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/package.json +1 -1
- package/src/bridge/board.js +5 -2
- package/src/bridge/main.js +126 -5
- package/src/bridge/pair.js +2 -0
- package/src/bridge/ring.js +427 -0
- package/src/bridge/service.js +402 -25
- package/src/bridge/state.js +53 -1
- package/src/http.js +5 -2
- package/src/protocol.js +704 -3
- package/src/relay/config.js +8 -0
package/src/http.js
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
export class RelayHTTPError extends Error {
|
|
4
4
|
status ;
|
|
5
5
|
code ;
|
|
6
|
-
|
|
6
|
+
/** The whole error body, for errors that carry more than a code (a ring_conflict's head). */
|
|
7
|
+
body ;
|
|
8
|
+
constructor(status , code , message , body = {}) {
|
|
7
9
|
super(message);
|
|
8
10
|
this.status = status;
|
|
9
11
|
this.code = code;
|
|
12
|
+
this.body = body;
|
|
10
13
|
}
|
|
11
14
|
}
|
|
12
15
|
|
|
@@ -20,7 +23,7 @@ export async function relayRequest (base , method , path
|
|
|
20
23
|
const text = await response.text();
|
|
21
24
|
let value = {};
|
|
22
25
|
try { value = JSON.parse(text); } catch { /* not JSON */ }
|
|
23
|
-
if (!response.ok) throw new RelayHTTPError(response.status, String(value.error ?? response.status), String(value.message ?? text.slice(0, 200)));
|
|
26
|
+
if (!response.ok) throw new RelayHTTPError(response.status, String(value.error ?? response.status), String(value.message ?? text.slice(0, 200)), value);
|
|
24
27
|
return value ;
|
|
25
28
|
}
|
|
26
29
|
|