<pre></pre>
class Hello extends HTMLElement {
  connectedCallback() {
    throw new Error('haha!')
  }
}

customElements.define('hello-world', Hello)

const element = document.createElement('hello-world')


let caughtError
try {
  document.body.appendChild(element)
} catch (error) {
  console.log('Caught error?', error)
  caughtError = error
}

document.querySelector('pre').innerHTML = 'Error was caught? ' + !!caughtError
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.