Update environment.py

make exception handling more explicit and remove unnecessary catches.