Record failed URL in more error messages

This commit is contained in:
Cadence Ember
2025-11-15 23:04:23 +13:00
parent 1338e6ba88
commit a2787f7b0b
2 changed files with 3 additions and 3 deletions

View File

@@ -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)

View File

@@ -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)
}
}