mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Get filename and line number into uncaught exception reports.
This commit is contained in:
parent
d7f0896429
commit
75ae8940c1
@ -51,9 +51,13 @@ public class EcmaError extends RuntimeException {
|
|||||||
*
|
*
|
||||||
* @param nativeError the NativeError object constructed for this error
|
* @param nativeError the NativeError object constructed for this error
|
||||||
*/
|
*/
|
||||||
public EcmaError(NativeError nativeError) {
|
public EcmaError(NativeError nativeError, String sourceName,
|
||||||
|
int lineNumber)
|
||||||
|
{
|
||||||
super("EcmaError");
|
super("EcmaError");
|
||||||
errorObject = nativeError;
|
errorObject = nativeError;
|
||||||
|
this.sourceName = sourceName;
|
||||||
|
this.lineNumber = lineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,6 +95,14 @@ public class EcmaError extends RuntimeException {
|
|||||||
return errorObject.getMessage();
|
return errorObject.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSourceName() {
|
||||||
|
return sourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLineNumber() {
|
||||||
|
return lineNumber;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the error object corresponding to this exception.
|
* Get the error object corresponding to this exception.
|
||||||
*/
|
*/
|
||||||
@ -99,4 +111,6 @@ public class EcmaError extends RuntimeException {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private NativeError errorObject;
|
private NativeError errorObject;
|
||||||
|
private String sourceName;
|
||||||
|
private int lineNumber;
|
||||||
}
|
}
|
||||||
|
@ -454,6 +454,24 @@ public class NativeGlobal {
|
|||||||
String error,
|
String error,
|
||||||
String message,
|
String message,
|
||||||
Object scope)
|
Object scope)
|
||||||
|
{
|
||||||
|
int[] linep = { 0 };
|
||||||
|
String filename = cx.getSourcePositionFromStack(linep);
|
||||||
|
return constructError(cx, error, message, scope,
|
||||||
|
filename, linep[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The NativeError functions
|
||||||
|
*
|
||||||
|
* See ECMA 15.11.6
|
||||||
|
*/
|
||||||
|
public static EcmaError constructError(Context cx,
|
||||||
|
String error,
|
||||||
|
String message,
|
||||||
|
Object scope,
|
||||||
|
String sourceName,
|
||||||
|
int lineNumber)
|
||||||
{
|
{
|
||||||
Scriptable scopeObject;
|
Scriptable scopeObject;
|
||||||
try {
|
try {
|
||||||
@ -466,7 +484,8 @@ public class NativeGlobal {
|
|||||||
Object args[] = { message };
|
Object args[] = { message };
|
||||||
try {
|
try {
|
||||||
Object errorObject = cx.newObject(scopeObject, error, args);
|
Object errorObject = cx.newObject(scopeObject, error, args);
|
||||||
return new EcmaError((NativeError)errorObject);
|
return new EcmaError((NativeError)errorObject, sourceName,
|
||||||
|
lineNumber);
|
||||||
}
|
}
|
||||||
catch (PropertyException x) {
|
catch (PropertyException x) {
|
||||||
throw new RuntimeException(x.toString());
|
throw new RuntimeException(x.toString());
|
||||||
|
@ -1305,8 +1305,8 @@ public class TokenStream {
|
|||||||
if (scope != null) {
|
if (scope != null) {
|
||||||
throw NativeGlobal.constructError(
|
throw NativeGlobal.constructError(
|
||||||
Context.getContext(), "SyntaxError",
|
Context.getContext(), "SyntaxError",
|
||||||
message,
|
message, scope, getSourceName(),
|
||||||
scope);
|
getLineno());
|
||||||
} else {
|
} else {
|
||||||
flags |= TSF_ERROR;
|
flags |= TSF_ERROR;
|
||||||
Context.reportError(message, getSourceName(),
|
Context.reportError(message, getSourceName(),
|
||||||
|
@ -89,6 +89,9 @@ msg.format3 =\
|
|||||||
msg.uncaughtJSException =\
|
msg.uncaughtJSException =\
|
||||||
uncaught JavaScript exception: {0}
|
uncaught JavaScript exception: {0}
|
||||||
|
|
||||||
|
msg.uncaughtJSExceptionLine =\
|
||||||
|
uncaught JavaScript exception ("{0}", line {1}): {2}
|
||||||
|
|
||||||
msg.jsc.usage =\
|
msg.jsc.usage =\
|
||||||
Didn''t understand "{0}". \n\
|
Didn''t understand "{0}". \n\
|
||||||
Valid arguments are: \n\
|
Valid arguments are: \n\
|
||||||
|
@ -360,9 +360,17 @@ public class Main {
|
|||||||
we.printStackTrace();
|
we.printStackTrace();
|
||||||
}
|
}
|
||||||
catch (EcmaError ee) {
|
catch (EcmaError ee) {
|
||||||
Context.reportError(ToolErrorReporter.getMessage(
|
if (ee.getSourceName() != null) {
|
||||||
"msg.uncaughtJSException",
|
Object[] args = { ee.getSourceName(),
|
||||||
ee.toString()));
|
new Integer(ee.getLineNumber()),
|
||||||
|
ee.toString() };
|
||||||
|
Context.reportError(ToolErrorReporter.getMessage(
|
||||||
|
"msg.uncaughtJSExceptionLine", args));
|
||||||
|
} else {
|
||||||
|
Context.reportError(ToolErrorReporter.getMessage(
|
||||||
|
"msg.uncaughtJSException",
|
||||||
|
ee.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (EvaluatorException ee) {
|
catch (EvaluatorException ee) {
|
||||||
// Already printed message, so just fall through.
|
// Already printed message, so just fall through.
|
||||||
|
@ -51,9 +51,13 @@ public class EcmaError extends RuntimeException {
|
|||||||
*
|
*
|
||||||
* @param nativeError the NativeError object constructed for this error
|
* @param nativeError the NativeError object constructed for this error
|
||||||
*/
|
*/
|
||||||
public EcmaError(NativeError nativeError) {
|
public EcmaError(NativeError nativeError, String sourceName,
|
||||||
|
int lineNumber)
|
||||||
|
{
|
||||||
super("EcmaError");
|
super("EcmaError");
|
||||||
errorObject = nativeError;
|
errorObject = nativeError;
|
||||||
|
this.sourceName = sourceName;
|
||||||
|
this.lineNumber = lineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,6 +95,14 @@ public class EcmaError extends RuntimeException {
|
|||||||
return errorObject.getMessage();
|
return errorObject.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSourceName() {
|
||||||
|
return sourceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLineNumber() {
|
||||||
|
return lineNumber;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the error object corresponding to this exception.
|
* Get the error object corresponding to this exception.
|
||||||
*/
|
*/
|
||||||
@ -99,4 +111,6 @@ public class EcmaError extends RuntimeException {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private NativeError errorObject;
|
private NativeError errorObject;
|
||||||
|
private String sourceName;
|
||||||
|
private int lineNumber;
|
||||||
}
|
}
|
||||||
|
@ -454,6 +454,24 @@ public class NativeGlobal {
|
|||||||
String error,
|
String error,
|
||||||
String message,
|
String message,
|
||||||
Object scope)
|
Object scope)
|
||||||
|
{
|
||||||
|
int[] linep = { 0 };
|
||||||
|
String filename = cx.getSourcePositionFromStack(linep);
|
||||||
|
return constructError(cx, error, message, scope,
|
||||||
|
filename, linep[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The NativeError functions
|
||||||
|
*
|
||||||
|
* See ECMA 15.11.6
|
||||||
|
*/
|
||||||
|
public static EcmaError constructError(Context cx,
|
||||||
|
String error,
|
||||||
|
String message,
|
||||||
|
Object scope,
|
||||||
|
String sourceName,
|
||||||
|
int lineNumber)
|
||||||
{
|
{
|
||||||
Scriptable scopeObject;
|
Scriptable scopeObject;
|
||||||
try {
|
try {
|
||||||
@ -466,7 +484,8 @@ public class NativeGlobal {
|
|||||||
Object args[] = { message };
|
Object args[] = { message };
|
||||||
try {
|
try {
|
||||||
Object errorObject = cx.newObject(scopeObject, error, args);
|
Object errorObject = cx.newObject(scopeObject, error, args);
|
||||||
return new EcmaError((NativeError)errorObject);
|
return new EcmaError((NativeError)errorObject, sourceName,
|
||||||
|
lineNumber);
|
||||||
}
|
}
|
||||||
catch (PropertyException x) {
|
catch (PropertyException x) {
|
||||||
throw new RuntimeException(x.toString());
|
throw new RuntimeException(x.toString());
|
||||||
|
@ -1305,8 +1305,8 @@ public class TokenStream {
|
|||||||
if (scope != null) {
|
if (scope != null) {
|
||||||
throw NativeGlobal.constructError(
|
throw NativeGlobal.constructError(
|
||||||
Context.getContext(), "SyntaxError",
|
Context.getContext(), "SyntaxError",
|
||||||
message,
|
message, scope, getSourceName(),
|
||||||
scope);
|
getLineno());
|
||||||
} else {
|
} else {
|
||||||
flags |= TSF_ERROR;
|
flags |= TSF_ERROR;
|
||||||
Context.reportError(message, getSourceName(),
|
Context.reportError(message, getSourceName(),
|
||||||
|
@ -89,6 +89,9 @@ msg.format3 =\
|
|||||||
msg.uncaughtJSException =\
|
msg.uncaughtJSException =\
|
||||||
uncaught JavaScript exception: {0}
|
uncaught JavaScript exception: {0}
|
||||||
|
|
||||||
|
msg.uncaughtJSExceptionLine =\
|
||||||
|
uncaught JavaScript exception ("{0}", line {1}): {2}
|
||||||
|
|
||||||
msg.jsc.usage =\
|
msg.jsc.usage =\
|
||||||
Didn''t understand "{0}". \n\
|
Didn''t understand "{0}". \n\
|
||||||
Valid arguments are: \n\
|
Valid arguments are: \n\
|
||||||
|
@ -360,9 +360,17 @@ public class Main {
|
|||||||
we.printStackTrace();
|
we.printStackTrace();
|
||||||
}
|
}
|
||||||
catch (EcmaError ee) {
|
catch (EcmaError ee) {
|
||||||
Context.reportError(ToolErrorReporter.getMessage(
|
if (ee.getSourceName() != null) {
|
||||||
"msg.uncaughtJSException",
|
Object[] args = { ee.getSourceName(),
|
||||||
ee.toString()));
|
new Integer(ee.getLineNumber()),
|
||||||
|
ee.toString() };
|
||||||
|
Context.reportError(ToolErrorReporter.getMessage(
|
||||||
|
"msg.uncaughtJSExceptionLine", args));
|
||||||
|
} else {
|
||||||
|
Context.reportError(ToolErrorReporter.getMessage(
|
||||||
|
"msg.uncaughtJSException",
|
||||||
|
ee.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (EvaluatorException ee) {
|
catch (EvaluatorException ee) {
|
||||||
// Already printed message, so just fall through.
|
// Already printed message, so just fall through.
|
||||||
|
Loading…
Reference in New Issue
Block a user