General code coverage
This commit is contained in:
+15
-15
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user