feat(app/actions): display plugins errors in logs (#1023) [skip ci]

This commit is contained in:
Simon Lecoq
2022-04-28 00:26:53 +02:00
committed by GitHub
parent ac68f3d880
commit 1bfa51af2e
2 changed files with 10 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ import processes from "child_process"
import fs from "fs/promises"
import paths from "path"
import sgit from "simple-git"
import util from "util"
import mocks from "../../../tests/mocks/index.mjs"
import metrics from "../metrics/index.mjs"
import presets from "../metrics/presets.mjs"
@@ -392,7 +393,12 @@ function quit(reason) {
info.break()
info.section("Rendering")
let rendered = await retry(async () => {
const {rendered} = await metrics({login: user, q}, {graphql, rest, plugins, conf, die, verify, convert}, {Plugins, Templates})
const {rendered, errors} = await metrics({login: user, q}, {graphql, rest, plugins, conf, die, verify, convert}, {Plugins, Templates})
if (errors.length) {
console.warn(`::group::${errors.length} error(s) occured`)
console.warn(util.inspect(errors, {depth: Infinity, maxStringLength: 256}))
console.warn("::endgroup::")
}
return rendered
}, {retries, delay: retries_delay})
if (!rendered)

View File

@@ -89,7 +89,7 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
}
return value
}))
return {rendered, mime: "application/json"}
return {rendered, mime: "application/json", errors}
}
//Markdown output
@@ -161,7 +161,7 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
rest,
})
}
return {rendered, mime: "text/html"}
return {rendered, mime: "text/html", errors}
}
//Rendering
@@ -197,7 +197,7 @@ export default async function metrics({login, q}, {graphql, rest, plugins, conf,
//Result
console.debug(`metrics/compute/${login} > success`)
return {rendered, mime}
return {rendered, mime, errors}
}
//Internal error
catch (error) {