Updated dweet.py for exception handling