Server catch usage


I’m trying to understand the exact details of a Catch within server connect. This is all just sandbox stuff, so I’m artificially throwing an error by setting mail1 to an invalid host, and then sending an email. I also have a valid smtp host (sendgrid_tos) for sending an email within the catch.

Here is what I’m experiencing (php)…

This configuration sends the email in the catch, but returns as status of 200 (I would expect a 400 because of the response):
sends mail - status 200

This config does not send the email and sends a status 400:
no send status 400

This config does not send the email and returns status 200:
no send - status 200

I guess my question is: Can I send an email (or do any other processing) in a Catch, and also set an error response code?

Related: If I try to add a Send Mail into a catch, the systems prompts me to setup a mailer first, even though mailers are setup in the Steps…by design, or bug?

Screen Shot 2020-10-14 at 8.12.07 AM

bump…

1 Like

Seeing your tests with the catch it looks like it is only executing the first step in the catch, it should however execute all the steps there as you would expect.

The confirmation for the mail setup is indeed wrong, Wappler checks if there is a mail setup step in front of the send step, it probably doesn’t detect this correctly when in the catch.

The catch is something that almost nobody seems to use and we are planning on a different implementation of it. I will check why it is not executing all the steps in the catch and post an update here as soon I have one.

I also found in the past some inconsistency when using the catch and was meaning to perform thorough testing but got driven away by other tasks. I was planning on using it though but I do understand why others would pass on this feature. Error handling is something that not many do.

What implementation have you guys got in mind? If you can explain high level.

This could well be a lack of understanding on what it is or how and when to use it. I’ve been error handling differently as I had no idea that I’d what that’s for. Now I know, I’d plan to use it so like JonL, keen to understand how this may change

1 Like

I’m also keen to start using the catch feature. I’m trying to send an email to me when a failed login occurs but it isn’t working and I’ve no idea why.

Hey Jon…currently you can only have a single action in the catch. I was able to send an email in the catch but had to put the mailer setup in the parent of the server connect.

Hmm. If I put the mailer setup anywhere apart from in the catch then it’s not available to the send mail mailer selection.

I’d be very interested to see your server connect if you get this working. This is something I would like to do as well. No idea where to start.

At the moment I have this:

Screenshot 2020-10-29 at 21.07.18

but it’s not working and it does seem @mebeingken’s mention of only one action will work in the catch area.

Okay, just looked again and here is how to make it work…

In the catch, add the Setup mailer you need, and then add the send mail action. Get it all setup.

Then drag the setup mailer, back to the parent.

And then make a comment in there so you don’t forget how to replicate like I did!

That’s not working for me unfortunately. I wonder if you did it initially with an older version of Wappler which no longer allows that trick?

Just did another one from scratch.

Maybe it is related to my test scenario:
Screen Shot 2020-10-29 at 2.13.10 PM

mail1 is setup with a bogus host, so the first Send Mail action fails, triggering the Catch, which performs a Send Mail action using the valid mailer with sendgrid.

Sending just fine.

PHP, btw.

1 Like

Thanks Ken. I shall persevere.

1 Like

I love this idea. Jon, just curious, are you taking information from the login form and getting it emailed to you on failed attempt? I think it would be great to send me at least the username that is being rejected.

Yes, I’m trying to send an email which contains the username posted from the form (not the password they tried) and some IP information so I know roughly where the attempt was from.

<p>Someone has attempted to log into your admin area.</p><p>Email: {{$_POST.username}}<br>IP Address: {{$_SERVER.REMOTE_ADDR}}<br>Location: {{apiResolveIP.data.city}}, {{apiResolveIP.data.zip}}<br>Country: {{apiResolveIP.data.country_name}} ({{apiResolveIP.data.country_code}})</p>

See this for how to convert the IP address into more meaningful info:

Great, this seems like the next logical step for me. I already record username and IP of valid logins into the database.

Yes, I’ve edited my previous post to give some more info on what I’m trying to achieve.

I’m afraid I just can’t get it to work so will give up for now. I see Patrick has been assigned so hopefully he’ll be able to look into it and find a solution.