#142: Use try-catch with IF statement

Resolves #142.