Update cosmogramma.py

fleshed out error handling