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):
This config does not send the email and sends a status 400:
This config does not send the email and returns 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?
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
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.
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.
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:
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.