diff --git a/src/matrix/api.js b/src/matrix/api.js index 69ef78d..e529d0f 100644 --- a/src/matrix/api.js +++ b/src/matrix/api.js @@ -396,7 +396,7 @@ async function getMedia(mxc, init = {}) { ...init }) if (res.status !== 200) { - throw await mreq.makeMatrixServerError(res, init) + throw await mreq.makeMatrixServerError(res, {...init, url}) } if (init.method !== "HEAD") { assert(res.body) diff --git a/src/matrix/mreq.js b/src/matrix/mreq.js index bed7951..384950e 100644 --- a/src/matrix/mreq.js +++ b/src/matrix/mreq.js @@ -27,9 +27,9 @@ async function makeMatrixServerError(res, opts = {}) { 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()}) + 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")}) + return new MatrixServerError({errcode: "CX_SERVER_ERROR", error: `Server returned HTTP status ${res.status}`, content_type: res.headers.get("content-type")}, opts) } }