From 506dfe8f8448c7255bbf1680fca50eeecbf8f2fb Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Mon, 30 Oct 2023 16:57:33 +1300 Subject: [PATCH] feat: Report parse failure reasons For [](https://github.com/asyncapi/generator/issues/1051) I opted for the more basic logging style - I don't know enough about the diagnostics objects to be sure that they'll always contain the same fields, so erred on the side of caution rather than trying to access fields within fields that aren't guaranteed to exist (as well as including all available information, regardless of what is provided). --- lib/generator.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/generator.js b/lib/generator.js index 0203f3a648..62819ba482 100644 --- a/lib/generator.js +++ b/lib/generator.js @@ -143,7 +143,7 @@ class Generator { * @example * await generator.generate(myAsyncAPIdocument); * console.log('Done!'); - * + * * @example * generator * .generate(myAsyncAPIdocument) @@ -353,6 +353,9 @@ class Generator { if (!document) { const err = new Error('Input is not a correct AsyncAPI document so it cannot be processed.'); err.diagnostics = diagnostics; + for (const diag of diagnostics) { + console.error('Diagnotic err:', diag); + } throw err; } else { this.asyncapi = document;