Error handling in Plaxis with Python

Hello,

I'm working on an automated model for designing simple retaining walls in Plaxis. 

The way the code works, is that it gradually increases the length of the retaining wall in a loop until a required FoS is achieved. 

However, if the length of the wall is too small, the model stops running as the "soil body collapses", in which case, I want the python code to increase the length of the wall automatically instead of completely stopping the code. 

Is there any way that I can handle this error in Python without having to manually increase the wall length and trying again? something like this:

If [soil body collapsed]:

      wallLength = wallLength + 0.5

      continue

Cheers,