My favorites | Sign in
Project Home Downloads Wiki Issues Source
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 27: Line number not given in exception message when some scripts don't parse.
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


Sign in to add a comment
 
Reported by Matthew....@gmail.com, Feb 10, 2009
Example bad output:
     [java] 726 [main] ERROR kiwiplan.qms.take.GenerateInterfaces  - Take
through an exception.
     [java] nz.org.take.nscript.ScriptException: Exception parsing line
     [java] 	at nz.org.take.nscript.ParserSupport.error(ParserSupport.java:54)
     [java] 	at nz.org.take.nscript.Parser.error(Parser.java:734)
     [java] 	at nz.org.take.nscript.Parser.parse(Parser.java:114)
     [java] 	at
nz.org.take.nscript.ScriptKnowledgeSource.getKnowledgeBase(ScriptKnowledgeSource.java:42)
     [java] 	at
kiwiplan.qms.take.GenerateInterfaces.run(GenerateInterfaces.java:74)
     [java] 	at
kiwiplan.qms.take.GenerateInterfaces.main(GenerateInterfaces.java:36)
     [java] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java] 	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java] 	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [java] 	at
org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
     [java] 	at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
     [java] 	at org.apache.tools.ant.taskdefs.Java.run(Java.java:747)
     [java] 	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:201)
     [java] 	at org.apache.tools.ant.taskdefs.Java.execute(Java.java:104)
     [java] 	at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
     [java] 	at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
     [java] 	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java] 	at java.lang.reflect.Method.invoke(Method.java:597)
     [java] 	at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
     [java] 	at org.apache.tools.ant.Task.perform(Task.java:348)
     [java] 	at org.apache.tools.ant.Target.execute(Target.java:357)
     [java] 	at org.apache.tools.ant.Target.performTasks(Target.java:385)
     [java] 	at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
     [java] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
     [java] 	at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
     [java] 	at
org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
     [java] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
     [java] 	at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
     [java] 	at
org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
     [java] Caused by: java.lang.NullPointerException
     [java] 	at nz.org.take.nscript.Parser.error(Parser.java:260)
     [java] 	at nz.org.take.nscript.Parser.parseRule(Parser.java:356)
     [java] 	at nz.org.take.nscript.Parser.parseLine(Parser.java:167)
     [java] 	at nz.org.take.nscript.Parser.parse(Parser.java:111)
     [java] 	... 27 more

Desc: Take sometimes gives the message "Exception passing line" without
giving line number.

Stack trace suggests line number is lost inside
nz.org.take.nscript.ScriptException.ScriptException(String,Throwable,int)
when calling super(String,Throwable). TakeException (the super class) calls
super(String,Throwable). This parses to Exception but Exception which
doesn't know about int line.

I'm using Trunk under Ubuntu. Doesn't matter what the underlying system is
though.

Suggested fix:
Inside ScriptException, replace
	public ScriptException(String arg0,int line) {
		super(arg0);
		this.line = line;
	}

	public ScriptException(Throwable arg0,int line) {
		super(arg0);
		this.line = line;
	}

	public ScriptException(String arg0, Throwable arg1,int line) {
		super(arg0, arg1);
		this.line = line;
	}

With

	public ScriptException(String arg0,int line) {
		super(arg0.contains(Integer.toString(line)) ? arg0 : arg0+" "+line);
		this.line = line;
	}

	public ScriptException(Throwable arg0,int line) {
		super(arg0);
		this.line = line;
	}

	public ScriptException(String arg0, Throwable arg1,int line) {
		super((arg0.contains(Integer.toString(line)) ? arg0 : arg0+" "+line), arg1);
		this.line = line;
	}
Sign in to add a comment

Powered by Google Project Hosting