Try/Catch in action

This is to help people who are using try catch and may be having issues or need to use it and don’t .

I was asked to write a system that would send 20K customised emails to students in a university on a thursday morning with the emails needing to go out monday morning. I fired up wappler and created the system in nodejs with a mysql db and ran it in a docker solution.

the standard aspects were put in such as import from CSV to the DB then the output to the university SMTP server so the emails were not flagged as external or picked up as spam.

The issue came with sending the emails with how to use try/catch

then of course it dawned on me that the way it works is

Try= the activity you want to happen normally
catch= the activity to occur when there is an issue

so the server connect action became this

  1. query for all records
  2. setup the mailer ( not required )
  3. add a repeat for all the returns in the query be sure to output the required values
  4. under steps add Try/catch
  5. under the try setup and send the email then update the database to show that the email has been sent ( I used a time stamp in a send field)
  6. under catch setup an email to go the person running the survey to say there was an issue with the mail for that person. and then record a message in the database it was not sent.

I did notice that using response stops the flow so its not used in the is case

I hope this helps other people tackling the same situation.

8 Likes