Also render subErrors as a tree for root-level errors
This commit is contained in:
parent
81e59302d2
commit
1cc19bff3e
|
@ -29,7 +29,7 @@ if (supportsColor.stderr) {
|
|||
closeColor = "";
|
||||
}
|
||||
|
||||
function renderErrorList(errors, basePath = []) {
|
||||
function renderErrorList(errors, isSubErrors = false) {
|
||||
let rephrasedErrors = errors.map((error, i) => {
|
||||
let pathSegments = error.path.map((segment) => {
|
||||
if (segment == null) {
|
||||
|
@ -47,13 +47,13 @@ function renderErrorList(errors, basePath = []) {
|
|||
? "├─"
|
||||
: "└─";
|
||||
|
||||
let mainLine = (basePath.length > 0)
|
||||
let mainLine = (isSubErrors)
|
||||
// ? `... -> ${joinPathSegments(pathSegments)}: ${error.message}`
|
||||
? ` ${lineCharacter} ${joinPathSegments(pathSegments)}: ${error.message}`
|
||||
: ` - At ${joinPathSegments(pathSegments)}: ${error.message}`;
|
||||
|
||||
if (error.subErrors != null && error.subErrors.length > 0) {
|
||||
let renderedSubErrors = renderErrorList(error.subErrors, error.path);
|
||||
let renderedSubErrors = renderErrorList(error.subErrors, true);
|
||||
|
||||
return mainLine + "\n" + indentString(renderedSubErrors, 2);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue