Moving back to python with error handling in hooks