Best way to write nested try/catch blocks

Organize your code differently. Traits would help in general, but may require more investment, hasmethod would be the quick & dirty way.

FWIW, if this is related to

then just use one of the solutions suggested there; if you are OK with random values then it makes little sense to attempt to get a zero first — pretty much the same types have rand and zero defined.