Safe exception handling in snap.py