I have the following code, my goal is to write to a pop up the console error message that results from calling the function "func". I am currently running it in chrome and although I get an error in the console I get no pop up. The reason I am doing this is that I will be running my code in another environment where I won't have access to the console so I would like to be able to extract the error messages so I can view them.
function func(){
return y
}
(function() {
var exLog = console.log;
console.log = function(msg) {
exLog.apply(this, arguments);
alert(msg);
}
})()
func()