asyncapi-react
asyncapi-react copied to clipboard
Option "errors: true" shows empty/blank page when document has errors
Description
As reported in VSCode AsyncAPI Preview: https://github.com/asyncapi/vs-asyncapi-preview/issues/200
After upgrading to latest: "@asyncapi/react-component": "^1.2.7"
It shows a blank page when document contains validation errors
This are the configuration options used:
hey @ivangsa The issue seems to occur due to unhandled undefined of the document object
try {
const { document } = await asyncapiParser.parse(content, parserOptions);
return { asyncapi: document };
} catch (err) {
return this.handleError(err as ErrorObject);
}
Here the document object turns out undefined and hence no error is thrown.
try {
const parseResult = await asyncapiParser.parse(content, parserOptions);
let error:({title:string} ) = {title:""};
if(parseResult.document === undefined) {
parseResult.diagnostics.forEach(diagnostic => {
if(diagnostic.code.toString().includes("error")) {
error.title = diagnostic.message.toString();
}
});
if(error.title === "") {
error.title = "Unexpected error while parsing the document.";
}
throw error;
}
return { asyncapi: parseResult.document };
} catch (err) {
return this.handleError(err as ErrorObject);
}
This is one way we could resolve this issue.
I will draft a PR for the same and we can communicate over it.
Hey @derberg if you may help guide through this it will be great.
This maybe an upstream error as the parser does not throw an error as of the latest version but rather an undefined document object witth a error message in the diganostic object
This issue has been automatically marked as stale because it has not had recent activity :sleeping:
It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.
There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.
Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.
Thank you for your patience :heart: