fix(plugins/traffic): warn rejected requests

This commit is contained in:
Simon Lecoq
2023-03-13 22:15:57 -04:00
parent 10885a11d9
commit 40956a5972

View File

@@ -20,11 +20,15 @@ export default async function({login, imports, data, rest, q, account}, {enabled
const response = promised.filter(({status}) => status === "fulfilled").map(({value}) => value) const response = promised.filter(({status}) => status === "fulfilled").map(({value}) => value)
//Handle error if all promises were rejected //Handle error if all promises were rejected
if (promised.filter(({status}) => status === "rejected").length === promised.length) { const rejected = promised.filter(({status}) => status === "rejected")
if (rejected.length === promised.length) {
if (promised.map(({reason}) => reason.message).every(error => /must have push access to repository/i.test(error))) if (promised.map(({reason}) => reason.message).every(error => /must have push access to repository/i.test(error)))
throw {error: {message: "Insufficient token scopes"}} throw {error: {message: "Insufficient token scopes"}}
throw new Error(promised[0].reason.message) throw new Error(promised[0].reason.message)
} }
else if (rejected.length) {
rejected.map(({reason}) => console.debug(`metrics/compute/${login}/plugins > traffic > warn > ${reason.message}`))
}
//Compute views //Compute views
console.debug(`metrics/compute/${login}/plugins > traffic > computing stats`) console.debug(`metrics/compute/${login}/plugins > traffic > computing stats`)