Scripted PixelMath Issue - No Abort / Exception Protection?

dcarr

Well-known member
Hello

Unlike other external scriptable objects, PixelMath does not appear to abort calling scripts when invalid parameter values are passed to the process.

This is an issue for me because I have developed long-running scripts within a scripting framework; and it is possible to complete the execution of (lengthy) scripts even when errors are reported midway by PixelMath in the Process Console.

The result is the same whether or not try/catch exception handling is provided. Is it possible that PixelMath is not throwing exceptions on errors?

I have provided a self-contained test script to demonstrate; it requires any image to be active.

Regards

Dean
 

Attachments

  • Test PixelMath.zip
    1.5 KB · Views: 62
Last edited:
Hi @dcarr,
if I understood correctly you would detect if PixelMath execution generated an error or not, correct? in your example you're not able to detect the issue in the try/catch block because the process instance execution does not throw an error if it fails, the error detection is different: read the returned value of the P.executeOn(view) instruction:

JavaScript:
view.beginProcess(UndoFlag_NoSwapFile);
let result = P.executeOn(view);
view.endProcess();
console.noteln("result: ", result);

you'll see that result is false when PixalMath had issues, true otherwise, in this way you can simply implement your fallback or stop logic by checking the execution result after the execution.

I hope this answered :)

Robyx
 
Roberto has nailed it: always use the value returned by ProcessInstance.executeOn() or ProcessInstance.executeGlobal() to check that the process has been executed correctly. Both functions return a Boolean value (true=OK, false=error).

Of course, you should also use a try...catch construct to handle possible exceptions thrown during execution of processes.
 
Back
Top