chartist-js / chartist

Simple responsive charts
https://chartist.dev
MIT License
13.34k stars 2.53k forks source link

[Bug]: More descriptive error message when DOM node for container was not found #1354

Closed gionkunz closed 1 year ago

gionkunz commented 2 years ago

Would you like to work on a fix?

Current and expected behavior

Currently, when Chartist is used in dynamic rendering situations or the wrong selector is passed to initialize Chartist, we are having a very unspecific error message directly from the DOM API:

[ERROR TypeError: Cannot read property 'querySelectorAll' of null]

We should catch this error and enrich it with better description of what went wrong so users know how to fix it.

Reproduction

Initialize Chartist with an invalid selector

Chartist version

v2.x

Possible solution

Enrich the error message