catch the correct exception type in example code

[ci skip]