Discussion:
Error when calling implicitly included function inside a catch block
(too old to reply)
g***@panix.com
2018-03-22 15:40:15 UTC
Permalink
Raw Message
I have this code in a script component:


myMsg("no errors yet");

try {
myMsg("still no errors yet");
throw("some error happened");
}
catch (err) {
myMsg("we got an error");
}

The first two calls to myMsg() work correctly, but when myMsg() is called
from the catch block, I get this error:

10:32:08,863 ERROR - CTGDIS077I Failed with error: Error calling method 'myMsg(string)' on an object of type 'Object [JavaScript Object]'.
10:32:08,863 ERROR - CTGDIS281E Error caused by: com.ibm.jscript.InterpretException: Script interpreter error, line=8, col=5: [TypeError] Error calling method 'myMsg(string)' on an object of type 'Object [JavaScript Object]'.

myMsg() is defined in an implicitly included script:

function myMsg(message)
{
if (message == null)
{
message = "";
}
task.logmsg("======== ERROR: " + message + " ========");
}

Any ideas?
Eddie Hartman
2018-03-26 08:11:17 UTC
Permalink
Raw Message
Post by g***@panix.com
myMsg("no errors yet");
try {
myMsg("still no errors yet");
throw("some error happened");
}
catch (err) {
myMsg("we got an error");
}
The first two calls to myMsg() work correctly, but when myMsg() is called
10:32:08,863 ERROR - CTGDIS077I Failed with error: Error calling method 'myMsg(string)' on an object of type 'Object [JavaScript Object]'.
10:32:08,863 ERROR - CTGDIS281E Error caused by: com.ibm.jscript.InterpretException: Script interpreter error, line=8, col=5: [TypeError] Error calling method 'myMsg(string)' on an object of type 'Object [JavaScript Object]'.
function myMsg(message)
{
if (message == null)
{
message = "";
}
task.logmsg("======== ERROR: " + message + " ========");
}
Any ideas?
I have tested your code with 7.2 and 7.1.1, putting myMsg() into a Resources > Script that is implicitly included in the AL, and it works for me.
Post by g***@panix.com
what version and fixpack level are you using?
what happens when you fire up the AL Debugger and then try to step into the myMsg call in the catch-block?
g***@panix.com
2018-03-26 23:26:45 UTC
Permalink
Raw Message
Post by Eddie Hartman
I have tested your code with 7.2 and 7.1.1, putting myMsg() into a Resources > Script that is implicitly included in the AL, and it works for me.
Post by g***@panix.com
what version and fixpack level are you using?
what happens when you fire up the AL Debugger and then try to step into the myMsg call in the catch-block?
In the GUI, Help -> About says I am running 7.2.

In that same window, clicking Installation Details and then selecting the Features tab shows a lot of Eclipse-related stuff, bit nothing that identifies itself as a fixpack.

Running the debugger gives the same error message complaining about an object
of type 'Object [JavaScript Object]'.

This code is in the Prolog - Before Init hook. Is this significant?

Thanks,

John G.
g***@panix.com
2018-03-26 23:36:25 UTC
Permalink
Raw Message
Post by g***@panix.com
This code is in the Prolog - Before Init hook. Is this significant?
I tried putting the code instead in a plain script component in the
Data Flow, and it produces the same error.

Thanks,

John G.
John Dell'Oso
2018-03-27 01:06:44 UTC
Permalink
Raw Message
Post by g***@panix.com
Post by g***@panix.com
This code is in the Prolog - Before Init hook. Is this significant?
I tried putting the code instead in a plain script component in the
Data Flow, and it produces the same error.
Thanks,
John G.
I tried Eddie's way (implicitly included script for the function definition), prologs (before and after init hooks) and inline script component in the data flow and the code works fine for me as well. With the inline script component you have to have the function definition before the call. I'm on version 7.1.1 FP7.

By the way to find your fix pack level - from a command prompt and the <TDI-HOME>/bin directory run the following command:

- applyUpdates.bat -queryreg

Cheers,
JD
Eddie Hartman
2018-03-27 20:30:43 UTC
Permalink
Raw Message
Prolog Hooks are fine as the execute before DAL cycling kicks in. And note that Help > SDI CE Version gives you version with fixpack level.
g***@panix.com
2018-03-28 14:48:57 UTC
Permalink
Raw Message
Post by Eddie Hartman
Prolog Hooks are fine as the execute before DAL cycling kicks in. And note that Help > SDI CE Version gives you version with fixpack level.
Ah ha! That says I'm running 7.2.0.3.

This is also the Linux version.

Thanks,

John G.

Loading...