diff --git a/source/app/web/instance.mjs b/source/app/web/instance.mjs index 6e52eff6..a45dcb67 100644 --- a/source/app/web/instance.mjs +++ b/source/app/web/instance.mjs @@ -196,6 +196,12 @@ console.debug(`metrics/app/${login} > 404 (user/organization not found)`) return res.status(404).send("Not found: unknown user or organization") } + //GitHub failed request + if ((error instanceof Error)&&(/this may be the result of a timeout, or it could be a GitHub bug/i.test(error.errors?.[0]?.message))) { + console.debug(`metrics/app/${login} > 502 (bad gateway from GitHub)`) + const {request} = error.errors[0].message.match(/`(?[\w:]+)`/)?.groups ?? null + return res.status(502).send(`Bad Gateway: GitHub failed to execute request ${request} (this may be the result of a timeout, or it could be a GitHub bug)`) + } //General error console.error(error) return res.status(500).send("Internal Server Error: failed to process metrics correctly") @@ -278,6 +284,12 @@ console.debug(`metrics/app/${login} > 400 (bad request)`) return res.status(400).send("Bad request: unsupported template") } + //GitHub failed request + if ((error instanceof Error)&&(/this may be the result of a timeout, or it could be a GitHub bug/i.test(error.errors?.[0]?.message))) { + console.debug(`metrics/app/${login} > 502 (bad gateway from GitHub)`) + const {request} = error.errors[0].message.match(/`(?[\w:]+)`/)?.groups ?? null + return res.status(502).send(`Bad Gateway: GitHub failed to execute request ${request} (this may be the result of a timeout, or it could be a GitHub bug)`) + } //General error console.error(error) return res.status(500).send("Internal Server Error: failed to process metrics correctly") diff --git a/source/app/web/statics/about/script.js b/source/app/web/statics/about/script.js index 61a73b19..4738002d 100644 --- a/source/app/web/statics/about/script.js +++ b/source/app/web/statics/about/script.js @@ -66,7 +66,7 @@ this.metrics = (await axios.get(`/about/query/${this.user}`)).data } catch (error) { - this.error = error + this.error = {code:error.response.status, message:error.response.data} } finally { this.pending = false