Cancel action or throw error on error condition?

Update: You can throw an error and stop a step from moving on by surprise… throw 'Error'. New question, now in my error condition I have:

if (isError) {
  app.displayErrorMessage('Draft is empty');
  throw `Error message helpful for debugging`;

Now when the Draft is empty, error message is displayed at the top, it’s closed. Then another error styled banner shows up with an ! and no message. Is there a way to combine these 2 into 1 or suppress the throw from displaying an error banner? Or is there a parameter to set the message of the 2nd error banner coming from throw?

Really minor, just would prefer to combine the 2 banners.


Original message:

Hey, I’m working on customizing an action where I’m formatting the Draft text, validating it, and saving it to dropbox. If it fails validation, I’ve tried using alert(message) as well as app.displayErrorMessage(message) and they both show the error message I want, but the invalid Draft still moves to step 2 and saves to dropbox.

How do I throw an error or cancel the Action from moving onto the next step?

(For a bit more context, in the case that the Draft is completely empty, the validation fails. I’m showing the error message but I don’t want the empty message saved in Dropbox.)


In reference to your original issue, have you taken a look at Context?

Thanks @sylumer! Context is really helpful for my use case :grin: