Added exception catching in the examples