Bug 62897
| Summary: | Using "throw" with a string doesn't result in url and line number being set in the exception. | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | David Levin <levin> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED DUPLICATE | ||
| Severity: | Normal | CC: | barraclough, ggaren, levin, oliver |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | All | ||
| OS: | All | ||
David Levin
I guess that there is a missing call to addErrorInfo somewhere.
Here's a test case:
<html>
<body>
This should result in a one line of output with a message, url and line number.
<div id=result></div>
<script type="text/javascript" language="javascript">
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
function log(message)
{
document.getElementById("result").innerHTML += message + "<br>";
}
window.onerror = function(msg, url, line) {
// Clean up url here to remove path.
log( "msg " + msg + " url " + url + " line " + line );
if (window.layoutTestController)
layoutTestController.notifyDone();
}
throw "Test Error";
</script>
</body>
</html>
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Oliver Hunt
(In reply to comment #0)
> I guess that there is a missing call to addErrorInfo somewhere.
>
Nope, you can't add properties to a string - strings aren't objects. This is a known (and sad making limitation in JSC, and there is a bug about it, but i can't find it :-/ )
Geoffrey Garen
Seems like we could replace a thrown string with a string object, or a generic error object used to wrap primitive values.
Oliver Hunt
(In reply to comment #2)
> Seems like we could replace a thrown string with a string object, or a generic error object used to wrap primitive values.
That would be behavioural bug -- if you throw a string, the caught value remains a string. We really just need to have an out of band mechanism for reporting where an exception came from.
Geoffrey Garen
(In reply to comment #3)
> (In reply to comment #2)
> > Seems like we could replace a thrown string with a string object, or a generic error object used to wrap primitive values.
>
> That would be behavioural bug -- if you throw a string, the caught value remains a string. We really just need to have an out of band mechanism for reporting where an exception came from.
We can distinguish between the value we pass to a catch block and the value we propagate as an exception. For example, in the generic error object design, we would unwrap the wrapped exception before running a catch block.
Gavin Barraclough
*** This bug has been marked as a duplicate of bug 18855 ***