cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Javascript errors do not go to java_console()

ptc-4742614
1-Newbie

Javascript errors do not go to java_console()

I have Javascript code embedded in a XUI dialog and I would like to see errors when something goes wrong. I think that the errors should go to the java console, but nothing ever shows up. Do I need to do something to get the errors to appear?

For example I might have code like:

do_something(foo);

But maybe 'foo' isn't really the right variable name, it should be 'bar'. when that line of code executes, nothing happens. Program execution stops, but no indication of the error shows up in the console.

I would really love to see an error like "foo is not defined" instead of having to just look through the code an imagine what might be going wrong.

2 REPLIES 2

Hi Mike--

In previous versions of Arbortext, Rhino would indeed show error messages in the Java Console. But recently I noticed that doesn't happen any more. I'm not sure if there's a way to change a setting somewhere to get that behavior back.

In the meantime, you have a few choices for working around the problem:

  1. You can wrap your code in try/catch blocks and report errors via Application.alert() or Application.print().
  2. You can switch to the MS JScript engine, and use the Microsoft Script Debugger to see what's going on. (That assumes that you're not using any Rhino-specific features like Packages.* to access Java objects.)

Or you could go old-school and liberally sprinkle Application.alert() statements throughout your code during debugging to report variable values and other diagnostic info to help pin down the problem.

--Clay

Clay,

Thanks for the answer. We can't switch to JScript because we are calling Java code from the JavaScript. I'll give the try/catch a go, that will be better than just bisecting the code with alerts until you find the error.

-Mike

Top Tags