try{ const elem = document.querySelector('.elem') if(!elem) throw new Error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) throw new Error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) throw new Error('Doing something else with elem has failed!') }catch(exception){ console.error(exception) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) const elem = document.querySelector('.elem') if(!elem) console.error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) console.error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) try{ const elem = document.querySelector('.elem') if(!elem) throw new Error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) throw new Error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) throw new Error('Doing something else with elem has failed!') }catch(exception){ console.error(exception) try{ const elem = document.querySelector('.elem') if(!elem) throw new Error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) throw new Error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) throw new Error('Doing something else with elem has failed!') }catch(exception){ console.error(exception) try{ const elem = document.querySelector('.elem') if(!elem) throw new Error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) throw new Error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) throw new Error('Doing something else with elem has failed!') }catch(exception){ console.error(exception) try{ const elem = document.querySelector('.elem') if(!elem) throw new Error('elem cannot be found!') const returnValue = functionThatDoesSomethingWithElem(elem) if(!returnValue.success) throw new Error('Doing something with elem has failed!') if(!returnValue.doSomethingElse()) throw new Error('Doing something else with elem has failed!') }catch(exception){ console.error(exception)