Repair error reporting

This commit is contained in:
Tony Garnock-Jones 2021-05-21 17:33:29 +02:00
parent 2ddedc7673
commit 1654ad4c80
2 changed files with 3 additions and 3 deletions

View File

@ -70,7 +70,7 @@ export function changeExt(p: string, newext: string): string {
export function formatFailures(failures: Array<Diagnostic>, traceback = false): void {
for (const d of failures) {
console.log(
console.error(
(d.type === 'error' ? chalk.redBright('[ERROR]') : chalk.yellowBright('[WARNING]'))
+ ' '
+ chalk.blueBright(formatPosition((d.detail as any).pos ?? d.file))
@ -81,6 +81,6 @@ export function formatFailures(failures: Array<Diagnostic>, traceback = false):
: ''));
}
if (failures.length > 0) {
console.log();
console.error();
}
}

View File

@ -6,7 +6,7 @@ export function checkSchema(schema: M.Schema): M.Schema {
const checker = new Checker();
schema.definitions.forEach(checker.checkDefinition.bind(checker));
if (checker.problems.length > 0) {
throw new Error(`Cannot produce unconverter: insufficient information in:\n` +
throw new Error(`Schema does not specify a bijection:\n` +
checker.problems.map(c => ' - ' + c).join('\n'));
}
return schema;