Skip to content

Commit d7a8ae5

Browse files
committed
Include first 10 errors in exception message
1 parent 0822fb1 commit d7a8ae5

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

lib/init-action.js

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config/db-config.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ test("parseUserConfig - throws a ConfigurationError if validation fails", (t) =>
457457
),
458458
{
459459
instanceOf: ConfigurationError,
460+
message:
461+
'The configuration file "test" is invalid: instance.queries is not of a type(s) array.',
460462
},
461463
);
462464

src/config/db-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ export function parseUserConfig(
506506
throw new ConfigurationError(
507507
errorMessages.getInvalidConfigFileMessage(
508508
pathInput,
509-
`There are ${result.errors.length} error(s)`,
509+
result.errors.map((e) => e.stack),
510510
),
511511
);
512512
}

src/error-messages.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ export function getConfigFileParseErrorMessage(
2323

2424
export function getInvalidConfigFileMessage(
2525
configFile: string,
26-
detail: string,
26+
messages: string[],
2727
): string {
28-
return `The configuration file "${configFile}" is invalid: ${detail}`;
28+
const andMore =
29+
messages.length > 10 ? `, and ${messages.length - 10} more.` : ".";
30+
return `The configuration file "${configFile}" is invalid: ${messages.slice(0, 10).join(", ")}${andMore}`;
2931
}
3032

3133
export function getConfigFileRepoFormatInvalidMessage(

0 commit comments

Comments
 (0)