import{isBuildMode as m}from"../utils/envs/is-build-mode.js";import{logger as n}from"../tools/notifiers/logger.js";import{isMarkdocError as d}from"../plugins/markdown/errors.js";import{reporter as r}from"../tools/notifiers/reporter.js";import{telemetryTraceStep as l}from"../../cli/telemetry/helpers/trace-step.js";async function b(i){await l("build.validation_errors",async s=>{let e=0;for(const[c,f]of i.cache.errors.entries()){const p=c.split(":")[1];for(const o of f)d(o)?(r.reportMarkdocProblem(o),o.type!=="BROKEN_LINK"&&e++):r.panicOnBuild(o.message,p)}const a=await i.getConfig();if(!m())return;const t=r.getPageRenderProblems().length;s?.setAttribute("markdocErrors",e.toString()),s?.setAttribute("pageRenderErrors",t.toString()),e>0&&!a?.reunite?.ignoreMarkdocErrors?(r.printErrors(),n.panic(`Need to fix ${e} Markdoc issue(s) or set the \`ignoreMarkdocErrors\` option to \`true\` in the \`reunite\` section of your \`redocly.yaml\``)):t>0&&(r.printErrors(),n.panic(`Need to fix ${t} runtime error(s) in React pages`))})}export{b as reportAllErrors};
