Catch only specified exception and simplify code.