Exception Handling

Hi all, so I’m attempting to handle the scenario in which my app cannot send a mail (for whatever reason, let’s assume the network is down). The mail step happens after I create a new user (I then subsequently do a query to get all of the new user’s info and not just the identity from the insert step).
In the catch step for the Send Mail action, I’m attempting to delete the user if the mail failed to send, however, it doesn’t seem to be working…the new user is created but never removed and no errors are thrown in the browser.

Please advise - thanks in advance.

The steps in the catch will run when your server action returns an error, such as server error (status 500).
Is that the case you tested?

Yes, this is the exception I’m attempting to catch and revert the creation of the new user account.

I’ve removed the steps in my catch block here and you can see the error in the browser:

What is the error status code returned by your server?


I think the error is returned by the following step:

so probably that’s why the catch is not triggering.

Oh, interesting. I’ll investigate and report back. That makes sense since it tries to establish a connection prior to sending the mail and that’s the step that fails.

1 Like

Okay, so if I move the Setup Mailer step into the repeater before the Send Mail action, like before, the browser no longer throws an error (not sure why this is the case now and in my first post), but the user is not removed.
If I leave the Setup Mailer step where it was and try to place the delete action in the catch block at the top level, I’m not sure how I can get a reference to the id of the created user to remove…

Any help is appreciated.

Strange, that the UI is not showing the query as an option.
Can you try something like {{query1[0].id}} for the delete?

Note: just replace the id in my expression with your identity column.

In the repeat, have you specified the fields which are to be made available like this?


Unfortunately no luck.

I wasn’t aware of this, tried it and still no luck. As you can see in my previous screenshots, I didn’t need to specify the output fields in order to bind to the exposed record’s properties, they were all just listed in the dynamic data picker.

The output is required only for the front end - when you want to make these available on your pages, on the server side it doesn’t make any difference, i.e. you can access the properties without enabling output.

I will test this locally and will let you know what’s wrong.

1 Like

Thanks @Teodor - I hope it’s not my ineptitude with Wappler that’s the cause :slight_smile:

I just tested the same case here and it seems to work pretty fine:

I added a setvalue just to test if the query returns any values, but i also see the query in the data picker:

The result is as expected, the value from the query is returned properly:


In your second screenshot, what step failed to throw the exception with the Set Value? Also, do exceptions bubble up (inner exception bubbles up to outer catch block)?

Sorry my screenshot was wrong, added the right one.

The step that fails is the mail setup step (i entered a wrong URL).

And yes, if there is something causing an error 500 in the repeat, the main level catch will “catch” it.

I’ve no idea why I can’t bind to the query from the catch block, I don’t have that option listed…

Are you using the latest version of Wappler?
What is your OS?

What if you try adding a setvalue with any value there in the catch? Does it run?

v2.1.5 on Windows 7.

Hard to know if the catch block is running as I’m calling this action from a server connect form (I don’t have a Server Connect component in my App Structure). Should I be doing something different?