Updated error handling in examples.