Update derive.py

make exception handling more explicit