# Parsing "Error: invalid argument"

**URL:** <https://forums.creativeclouddeveloper.com/t/parsing-error-invalid-argument/5760>\
**Category:** Photoshop\
**Created:** [January 27, 2023, 11:30pm UTC](https://forums.creativeclouddeveloper.com/t/parsing-error-invalid-argument/5760 "2023-01-27T23:30:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rascheln](https://avatars.discourse-cdn.com/v4/letter/r/e19b73/32.png) [@rascheln](https://forums.creativeclouddeveloper.com/u/rascheln)\
**Post date:** [January 27, 2023, 11:30pm UTC](https://forums.creativeclouddeveloper.com/t/parsing-error-invalid-argument/5760/1 "2023-01-27T23:30:52Z")

</div>

I have a button which merges layers (as a test) and I’ve put it inside a try/catch block to investigate what happens:

```auto
async function mergeSelectedLayers() {
  const batchCommands = [eventMergeLayers];
  try {
    return await executeAsModal(batchPlay(batchCommands, {}), { commandName: "Merge Selected Layers" });
  } catch (e) {
    console.log(`${e}`);
  }
}

```

where

```auto
const eventMergeLayers = {
  "_obj": "mergeLayersNew",
  "_isCommand": true
};

```

is the event descriptor for a layer merge, via Alchemist.

I am getting “Error: invalid argument” but the merging of the layers still occurs. The argument is generic enough that it’s tough to figure out where it’s coming from. What’s spitting out the error? It may give me some insight into why certain action descriptors fail to play.

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [January 28, 2023, 8:41am UTC](https://forums.creativeclouddeveloper.com/t/parsing-error-invalid-argument/5760/2 "2023-01-28T08:41:44Z")

</div>

Try changing to

```auto
    return await executeAsModal(() => batchPlay(batchCommands, {}), { commandName: "Merge Selected Layers" });

```

You need to pass a function to exeModal and not just some result of any type

---

<div class="post-metadata">

**Author:** ![rascheln](https://avatars.discourse-cdn.com/v4/letter/r/e19b73/32.png) [@rascheln](https://forums.creativeclouddeveloper.com/u/rascheln)\
**Post date:** [January 30, 2023, 5:56pm UTC](https://forums.creativeclouddeveloper.com/t/parsing-error-invalid-argument/5760/3 "2023-01-30T17:56:40Z")

</div>

Thanks for this information! That makes sense. What’s being passed in the first argument is, thus, an object describing the function, and not an evaluation of the function itself.
