JSFiddle - React, Tailwind, and code Playground
by Paulpro
HTML
<div id="test"></div>
JavaScript
(function(){
var _$ = $;
$ = function(){
var $res = _$.apply(0, arguments);
if(!$res.length && typeof arguments[0] === 'string')
throw 'No Element Found';
return $res;
}
})();
try{
// Throws Exception
$('span#test').text('FOO');
}catch(err){
console.log('Caught: '+err);
// Works correctly
$('#test').text('BAR');
}
// Throws Exception
$('.nothing').css('color', '#0000FF');
// Uncaught exceptions stop execution in javascript
$('#test').text('This line isn\'t reached');