No error messages being thrown when using UXP functions

Can anyone provide an explanation as to why I would not be receiving any errors on the console when I make calls to UXP function such as app.open?
Im no expert in this space, and Ive been getting some great assistance from @Timothy_Bennett, but my environment seems to not throw any errors to the console when calling functions that I believe are inbuilt. Normal basic programming errors are shown and I can work those out, but I am of course lost when my plugin just stops with no explanation. I’ve received help and now have basic understanding of executeAsModal etc, but I’m told that when I wasn’t using that it SHOULD have produced some form of console error.
Any suggestions appreciated. Thanks in advance.

Not much to go on here. Any example functions that you know are failing silently? I would first try wrapping your code in a try-catch:

function () {
	try {
		// code
	} catch(e) {
		require("photoshop").app.showAlert(e.message);
	}
}

If that’s still silent, you might be using batchPlay calls? They do not alert you to issues. You’ll need to log your calls to see what going on.

const bp = await batchPlay(...);
console.log(bp);

I haven’t had a chance to go back and run some tests with @Symo470’s original code that wasn’t returning errors yet, but it seemed like when executeAsModal sits inbetween two try/catch statements it doesn’t allow for a error to be thrown from a “child” try/catch to a “parent” (if that makes sense).
I’m hoping to have some time over the weekend to analyse further.

If the item you are calling returns a Promise, then make sure you have an “await” before the call.

Then at the end you can “then” it to get the errors:

await batchPlay(...).then(result => console.log(result), error => console.log(error));

This outputs both the results of the Promise and any errors in execution directly to the console.

This method works for any Promise, I think, even if the batchPlay is already inside try/catch. I’ve found the errors quite descriptive in helping resolve execution issues.

I use batchPlay almost exclusively instead of APIs, but if the API returns a Promise, I think this should work.

Just to be clear “app.open” is not a function. It needs the parentheses: app.open()

So maybe try:

// Show open file dialog
const document = await app.open().then(result => console.log(result), error => console.log(error));

and see what happens since app.open() returns a Promise.

I’m definitely not an expert in this, by maybe this thought process will help you figure it out.

The more I tinker, the more I think I have misinterpreted the ‘no errors’ thing.
I expected that if I called app.open incorrectly, it would throw an error to the console, which is my understanding for all incorrectly called functions.
So, what I am experiencing, is no error, but it simply doesn’t do anything, and just hangs… which for a rookie, can be quite confusing.
I have rewritten the code (x100) and I now have app.open working.