(this goes to future readers that don't get why this is wrong) You are supposed to catch and handle exceptions, not ignore them. People that develop these functions rely on you catching exceptions to be able to properly react to them breaking. Elegance and beauty are in the eyes of the beholder, and as with any piece of art, you write it so that other people will enjoy it. And everyone gets try...catch
blocks.
There's no way to do it in 1 line of code. You can however, do some nasty stuff to bypass exception handling.
METHOD 1
Manually handle the global onError method.
function handleErr(msg, url, line_no){
var errorMsg = "Error: " + msg + "\n";
errorMsg += "URL: " + url + "\n";
errorMsg += "Line: " + line_no + "\n\n";
console.log(errorMsg);
return true;
}
// Set the global onerror;
onerror = handleErr;
Now you handle (i.e. ignore) errors in this function. You can switch it on and off with a bit code. Or you can go bananas and just do a return true;
in the handler.
METHOD 2
Use setTimeout, the thread will die due to the exception but your code will keep executing, also a beautiful ES6 one-liner.
setTimeout(() => JSON.parse("not json: fghfghg"), 0)
console.log("Code still running")
METHOD 3
For non-mainstream, "Elegant" exception handling you can implement and use Either (example)