#2335 Type.doc()

SlimerDude Tue 26 Aug 2014

Type.doc() says:

Return the raw fandoc for this type or null if not available.

Which is great, and I test the value of doc to see if it is null or not. Only the method has a nasty side effect, see doc() in ClassType.java:

try
{
  InputStream in = pod.fpod.store.read("doc/" + name + ".apidoc");
  if (in != null) { try { new FDoc(in, this).read(); } finally { in.close(); } }
}
catch (Exception e) { e.printStackTrace(); }
docLoaded = true;

When doc returns null it also prints out a stack trace.

I'm calling this in a test runner where std out / std err is an important output. And currently it looks like all my tests are failing!

Is that e.printStackTrace() really needed? If so, could it not be logged instead so I have the option of turning it off?

brian Tue 26 Aug 2014

What the exception? That shouldn't happen unless something is really wrong - its sort of a last ditch just so that an error is silently ignored

SlimerDude Tue 26 Aug 2014

I get a NullErr when the .apidoc file doesn't exist.

java.lang.NullPointerException
  at fan.sys.ClassType.doc(ClassType.java:247)
  ...

Happens when a class is run as a script, pod.fpod.store comes back as null.

When running individual test classes with fant, they're always compiled as a script.

brian Tue 26 Aug 2014

That is a bug, we should handle that better. I pushed a fix

SlimerDude Tue 26 Aug 2014

Thanks! :)

Login or Signup to reply.