Show clear error when rendering VegaLite plot fails (#362)

This commit is contained in:
Jonatan Kłosko 2021-06-17 18:24:03 +02:00 committed by GitHub
parent 6f724f7146
commit 9d4139529e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,9 +36,15 @@ const VegaLite = {
spec.data = { values: [] };
}
this.state.viewPromise = vegaEmbed(this.state.container, spec, {}).then(
(result) => result.view
);
this.state.viewPromise = vegaEmbed(this.state.container, spec, {})
.then((result) => result.view)
.catch((error) => {
const message = `Failed to render the given Vega-Lite specification, got the following error:\n\n ${error.message}\n\nMake sure to check for typos.`;
this.state.container.innerHTML = `
<div class="text-red-600 whitespace-pre-wrap">${message}</div>
`;
});
});
this.handleEvent(