• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

JS error handling in edge problems

Question

neufuse    3,901

Anyone do JS dev on edge? I have a site that is using extensive AJAX and JS / jQuery / etc

 

The site has a global error handler set up on window.onerror (only to catch unhandled exceptions and log them on the server via posting the error detail back as a json package) which works perfectly fine in IE11, Chrome, FF, Safari, but when I do the same exact thing in Edge, if the function executed in JS has an error its like the function just will not run. to test this I set up just a junk function and called it with a button press, <button onclick = "testfunc(this);"> pretty simple, put into that function some code that just says 

 

function testfunc(button) {

throw new Error('test');

}

 

simple right? In Chrome, IE11, Safari, FF I get my error handler with that error message...

 

in Edge, that function doesn't even start to execute... remove the throw new error and put in a junk call like foo(); which is an undefined function same result.... replace that with alert('hello?'); and boom executes.....

 

JS isn't my primary language (actually never used it much until recently, was primary a back-end coder before) so am I missing something, doing something wrong? what? Or is something different with the Edge JS engine?

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0
neufuse    3,901

no one?

Share this post


Link to post
Share on other sites
  • 0
svnO.o    27
On 7/18/2016 at 9:53 AM, neufuse said:

no one?

I setup the following code on a test.html page and ran it on IE Edge and the alert is showing up just fine for me - 

 

<script type="text/javaScript">

window.onerror = function(message, source, lineno, colno, error)
{
	alert(message + ": " + source + " : " + lineno + " : " + colno + ": " + error);
}

function testfunc(button) {
	throw new Error('test');
}
</script>

<button onclick="testfunc(this);">Test</button>

 

Share this post


Link to post
Share on other sites
  • 0
neufuse    3,901
On ‎7‎/‎24‎/‎2016 at 0:25 AM, svnO.o said:

I setup the following code on a test.html page and ran it on IE Edge and the alert is showing up just fine for me - 

 


<script type="text/javaScript">

window.onerror = function(message, source, lineno, colno, error)
{
	alert(message + ": " + source + " : " + lineno + " : " + colno + ": " + error);
}

function testfunc(button) {
	throw new Error('test');
}
</script>

<button onclick="testfunc(this);">Test</button>

 

copied and pasted that into a local html file..... same problem..... testfunc will not execute *scratches head* maybe it's the build I'm on

Share this post


Link to post
Share on other sites
  • 0
svnO.o    27
1 hour ago, neufuse said:

copied and pasted that into a local html file..... same problem..... testfunc will not execute *scratches head* maybe it's the build I'm on

If it helps, I tested on Edge 25.10586.0.0 / EdgeHTML 13.10586 - other than that maybe some odd browser setting? I'd not worry too much though if its working in the other browsers as well as in the Edge browser version I tried.

Share this post


Link to post
Share on other sites
  • 0
neufuse    3,901
8 hours ago, svnO.o said:

If it helps, I tested on Edge 25.10586.0.0 / EdgeHTML 13.10586 - other than that maybe some odd browser setting? I'd not worry too much though if its working in the other browsers as well as in the Edge browser version I tried.

I just find it odd that the function wont even enter... I could put an alert('test'); before the throw new error and set a break point on it, never enters...

 

remove the throw new error do the same thing and boom alert executes... just very odd, you would think it would at least enter the function

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.