ANW
14 years agoContributor
Possible to restart a function on certain conditions?
I have a test where I create a new customer in my system. During creation I make a lookup to an official register of all people here in Denmark. I use the person's social security number to find name and address information.
however, once in a while, the person I am trying to look up is address protected, and thus I get an error. My problem is that I have no idea if the selected person (chosen randomly in our database at script start) is address protected or not.
Currently all I can do when that happens is stop the script and retry.
but is there a way I can restart the whole script if I encounter this type of error? ... basically I just want my script to report a warning in my log, and then retry.
I am aware that I can somehow put a giant loop around the whole script, and then repeat until a customer gets through validation. But is that the best/only way of doing this?
I would then have to make this loop in every script where I create new customers.
however, once in a while, the person I am trying to look up is address protected, and thus I get an error. My problem is that I have no idea if the selected person (chosen randomly in our database at script start) is address protected or not.
Currently all I can do when that happens is stop the script and retry.
but is there a way I can restart the whole script if I encounter this type of error? ... basically I just want my script to report a warning in my log, and then retry.
I am aware that I can somehow put a giant loop around the whole script, and then repeat until a customer gets through validation. But is that the best/only way of doing this?
I would then have to make this loop in every script where I create new customers.