AppleScript 生成未在参考中列出的未知错误 table

AppleScript generates an unknown error which is not listed in the reference table

我收到这个错误: test.scpt:脚本错误-41。由于错误 -1700,无法获取错误文本。

AppleScript 内容:

tell application "Adobe Photoshop CC 2019"
activate
set js to "#include '/Users/temp_myname/My Application/tmp/Adobe Scripts/script.jsx';" & return
delay 3
do javascript js
end tell

JSX 脚本内容:

#target photoshop
var err = "";
app.bringToFront();
app.displayDialogs = DialogModes.ERROR;
var fileRef = new File("/Users/temp_myname/My Application/tmp/10.20.5.18/default_10/Images/889original.jpg");
try{
open(fileRef);
} catch (Error) { err = Error }
;fileRef = null;
var errorFile = new File("/Users/temp_myname/My Application/tmp/Adobe Scripts/psperr.txt");
errorFile.open("w");
errorFile.write(err);
errorFile.close();
errorFile = null;

function runMenuItem(item) {
cTID = function(s) { return app.charIDToTypeID(s); };var desc = new ActionDescriptor();var ref = new ActionReference();ref.putEnumerated( cTID( "Mn  " ), cTID( "MnIt" ), item );desc.putReference( cTID( "null" ), ref );executeAction( cTID( "slct" ), desc, DialogModes.NO );
}

OSX版本:10.14.6

此脚本如何生成错误代码 -1700?相同的脚本在另一个 Mac(具有相同的配置)上工作得很好。

-41 是什么意思?我在参考资料里找不到table:

Error Numbers and Error Messages

从那个页面我得到了错误代码 -1700 的描述:

Bad parameter data was detected or there was a failure while performing a coercion.

我检查了文件权限,重置了 Finder,禁用了病毒扫描程序,卸载了卷...我还添加了 osascript 和 extendscript executables 到系统安全设置。

你怎么看?我怎样才能使这项工作?

顺便说一句。我 运行 来自使用 OpenJDK 的 Java 应用程序的 AppleScript,如下所示:

Runtime rt = Runtime.getRuntime();
Process proc;
String[] process;

process = new String[2];
process[0] = "osascript";
process[1] = "/Users/temp_myname/My Application/tmp/Adobe Scripts/test.scpt";
proc = rt.exec(process);

此问题已修复。 诀窍是在两个这样的 AppleScript 的执行之间添加一个睡眠。

错误代码 -41 是一个 OSX 错误代码,可以在 MacErrors.h 中找到: mFulErr = -41, /内存已满(打开)或文件不适合(加载)/