Prevent exception with try-catch