Minify for error-reporting

Apr 14, 2014 at 7:40 AM
Hi,

is it possible to minify a file in a way that in each line there is only one error that can occur?

What do I need this for?
In my application, all javascript that belongs to the page is minified into a single file on the fly (and cached on client- and server-side of course). BUT the error-reporting does not work very well anymore: All javascript-errors get reported to me automatically (window.onerror) with the error's filename, the line-number and the error-message. While the filename points to the source's url, the line-number does not help very much anymore.

So here is my idea:
The minifier could add line breaks in a way that in each line there is only one error that can occur.
One example:
if (obj1.checkSomething() && ob2.checkSomething()) {
    value1 = true;
}
Normally, this will be minified to:
if(a.checkSomething()&&b.checkSomething()){c=!0}
Now, sooner or later, I get the message "The object does not support checkSomething()" from this line. And I have no way of knowing, whether the issue occurred while accessing a or b.
So to avoid this, the minifier might add line-breaks in the appropriate positions:
if(a.checkSomething()
&&b.checkSomething()){c=!0}
Now, every error-message will come from a distinct line.

In this example, the overhead is only 2% (before compression). And the error-reporting will be even better than in the non-minified code!

Any chance, this might get implemented?

Regards
Andreas

PS: Currently, as a workaround, I use a max-line-length of 10 charachters. This works pretty well and I did not find a single line with two possible errors yet. But it also wastes some space since there are now some lines where no error can ever occur.