Fixing bug 95480. JS error messages were sometimes lost, we printed the filename and linenumber to the console, but the actual message was lost... r=pollmann@netscape.com, sr=vidur@netscape.com

This commit is contained in:
jst%netscape.com 2001-08-16 04:05:10 +00:00
Родитель 07b9fe80ef
Коммит 28ed0b96db
2 изменённых файлов: 24 добавлений и 12 удалений

Просмотреть файл

@ -3199,14 +3199,16 @@ GlobalWindowImpl::SetTimeoutOrInterval(PRBool aIsInterval, PRInt32 *aReturn)
if (argc < 1) {
::JS_ReportError(cx, "Function %s requires at least 1 parameter",
aIsInterval ? kSetIntervalStr : kSetTimeoutStr);
return NS_ERROR_FAILURE;
return ncc->SetExceptionWasThrown(PR_TRUE);
}
if (argc > 1 && !::JS_ValueToNumber(cx, argv[1], &interval)) {
::JS_ReportError(cx,
"Second argument to %s must be a millisecond interval",
aIsInterval ? kSetIntervalStr : kSetTimeoutStr);
return NS_ERROR_ILLEGAL_VALUE;
return ncc->SetExceptionWasThrown(PR_TRUE);
}
switch (::JS_TypeOfValue(cx, argv[0])) {
@ -3226,7 +3228,8 @@ GlobalWindowImpl::SetTimeoutOrInterval(PRBool aIsInterval, PRInt32 *aReturn)
default:
::JS_ReportError(cx, "useless %s call (missing quotes around argument?)",
aIsInterval ? kSetIntervalStr : kSetTimeoutStr);
return NS_ERROR_FAILURE;
return ncc->SetExceptionWasThrown(PR_TRUE);
}
timeout = new nsTimeoutImpl();

Просмотреть файл

@ -147,21 +147,30 @@ NS_ScriptErrorReporter(JSContext *cx,
}
if (report) {
nsAutoString fileUni;
nsAutoString fileUni, msg;
fileUni.AssignWithConversion(report->filename);
const PRUnichar *newFileUni = fileUni.ToNewUnicode();
PRUint32 column = report->uctokenptr - report->uclinebuf;
rv = errorObject->Init(NS_REINTERPRET_CAST(const PRUnichar*, report->ucmessage), newFileUni,
NS_REINTERPRET_CAST(const PRUnichar*, report->uclinebuf), report->lineno,
column, report->flags, category);
nsMemory::Free((void *)newFileUni);
const PRUnichar *m = NS_REINTERPRET_CAST(const PRUnichar*,
report->ucmessage);
if (!m && message) {
msg.AssignWithConversion(message);
m = msg.get();
}
rv = errorObject->Init(m, fileUni.get(),
NS_REINTERPRET_CAST(const PRUnichar*,
report->uclinebuf),
report->lineno, column, report->flags,
category);
} else if (message) {
nsAutoString messageUni;
messageUni.AssignWithConversion(message);
const PRUnichar *newMessageUni = messageUni.ToNewUnicode();
rv = errorObject->Init(newMessageUni, nsnull, nsnull,
rv = errorObject->Init(messageUni.get(), nsnull, nsnull,
0, 0, 0, category);
nsMemory::Free((void *)newMessageUni);
}
if (NS_SUCCEEDED(rv))