Match any function name in error

This commit is contained in:
Sidharth Vinod
2023-08-12 16:41:11 +05:30
parent 698395ef52
commit 0644fdfee6

View File

@@ -271,13 +271,15 @@ if (typeof document !== 'undefined') {
*/ */
window.addEventListener('load', contentLoaded, false); window.addEventListener('load', contentLoaded, false);
window.addEventListener('error', ({ message }) => { window.addEventListener('error', ({ message }) => {
if (message.includes('mermaid.initialize is not a function')) { // Get mermaid function called from error message with regex
const match = message.match(/mermaid\.(\w+) is not a function/);
if (match) {
const notify = () => const notify = () =>
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(`------------------------------ console.error(`------------------------------
Breaking change in Mermaid v11 Breaking change in Mermaid v11
------------------------------ ------------------------------
Use mermaid.default.initialize() instead of mermaid.initialize() Use mermaid.default.${match[1]}() instead of mermaid.${match[1]}()
Read more: https://github.com/mermaid-js/mermaid/releases/tag/v11.0.0 Read more: https://github.com/mermaid-js/mermaid/releases/tag/v11.0.0
`); `);
notify(); notify();