forked from cadence/out-of-your-element
send sim messages to the proper rooms
This commit is contained in:
parent
7526d63690
commit
da6603d258
10 changed files with 38 additions and 10 deletions
|
@ -11,11 +11,12 @@ const reg = sync.require("./read-registration.js")
|
|||
const baseUrl = "https://matrix.cadence.moe/_matrix"
|
||||
|
||||
class MatrixServerError extends Error {
|
||||
constructor(data) {
|
||||
constructor(data, opts) {
|
||||
super(data.error || data.errcode)
|
||||
this.data = data
|
||||
/** @type {string} */
|
||||
this.errcode = data.errcode
|
||||
this.opts = opts
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +39,7 @@ async function mreq(method, url, body, extra = {}) {
|
|||
const res = await fetch(baseUrl + url, opts)
|
||||
const root = await res.json()
|
||||
|
||||
if (!res.ok || root.errcode) throw new MatrixServerError(root)
|
||||
if (!res.ok || root.errcode) throw new MatrixServerError(root, opts)
|
||||
return root
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue