Skip to content

Commit 43daeaa

Browse files
committed
Build better error about missing props
1 parent b9c39de commit 43daeaa

File tree

2 files changed

+961
-421
lines changed

2 files changed

+961
-421
lines changed

internal/lsp/lsproto/_generate/generate.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ function generateCode() {
861861
writeLine("");
862862
writeLine(`import (`);
863863
writeLine(`\t"fmt"`);
864+
writeLine(`\t"strings"`);
864865
writeLine("");
865866
writeLine(`\t"github.com/go-json-experiment/json"`);
866867
writeLine(`\t"github.com/go-json-experiment/json/jsontext"`);
@@ -974,11 +975,13 @@ function generateCode() {
974975
writeLine("");
975976

976977
writeLine(`\tif missing != 0 {`);
978+
writeLine(`\t\tvar missingProps []string`);
977979
for (const prop of requiredProps) {
978980
writeLine(`\t\tif missing&missing${titleCase(prop.name)} != 0 {`);
979-
writeLine(`\t\t\treturn fmt.Errorf("required property '${prop.name}' is missing")`);
981+
writeLine(`\t\t\tmissingProps = append(missingProps, "${prop.name}")`);
980982
writeLine(`\t\t}`);
981983
}
984+
writeLine(`\t\treturn fmt.Errorf("missing required properties: %s", strings.Join(missingProps, ", "))`);
982985
writeLine(`\t}`);
983986

984987
writeLine("");

0 commit comments

Comments
 (0)