General code coverage

This commit is contained in:
Cadence Ember
2026-01-09 03:49:32 +13:00
parent 0d15865bcd
commit 045fdfdf27
12 changed files with 331 additions and 43 deletions
+15 -15
View File
@@ -18,21 +18,6 @@ class MatrixServerError extends Error {
}
}
/**
* @param {Response} res
* @param {object} opts
*/
async function makeMatrixServerError(res, opts = {}) {
delete opts.headers?.["Authorization"]
if (res.headers.get("content-type") === "application/json") {
return new MatrixServerError(await res.json(), opts)
} else if (res.headers.get("content-type")?.startsWith("text/")) {
return new MatrixServerError({errcode: "CX_SERVER_ERROR", error: `Server returned HTTP status ${res.status}`, message: await res.text()}, opts)
} else {
return new MatrixServerError({errcode: "CX_SERVER_ERROR", error: `Server returned HTTP status ${res.status}`, content_type: res.headers.get("content-type")}, opts)
}
}
/**
* @param {undefined | string | object | streamWeb.ReadableStream | stream.Readable} body
* @returns {Promise<string | streamWeb.ReadableStream | stream.Readable | Buffer>}
@@ -52,6 +37,21 @@ async function _convertBody(body) {
/* c8 ignore start */
/**
* @param {Response} res
* @param {object} opts
*/
async function makeMatrixServerError(res, opts = {}) {
delete opts.headers?.["Authorization"]
if (res.headers.get("content-type") === "application/json") {
return new MatrixServerError(await res.json(), opts)
} else if (res.headers.get("content-type")?.startsWith("text/")) {
return new MatrixServerError({errcode: "CX_SERVER_ERROR", error: `Server returned HTTP status ${res.status}`, message: await res.text()}, opts)
} else {
return new MatrixServerError({errcode: "CX_SERVER_ERROR", error: `Server returned HTTP status ${res.status}`, content_type: res.headers.get("content-type")}, opts)
}
}
/**
* @param {string} method
* @param {string} url